chore: check for missing files on start

This commit is contained in:
HorizonCode 2025-07-07 18:28:18 +02:00
parent 2082beb387
commit 1ab19957ba
4 changed files with 43 additions and 8 deletions

View File

@ -639,3 +639,32 @@ pub fn exit(app: AppHandle) {
pub fn get_platform() -> String { pub fn get_platform() -> String {
std::env::consts::OS.to_string() std::env::consts::OS.to_string()
} }
#[tauri::command]
pub async fn check_for_corruption(folder: String) -> Result<bool, String> {
let osu_path = PathBuf::from(folder);
let osu_ui = osu_path.join("osu!ui.dll");
let osu_gameplay = osu_path.join("osu!gameplay.dll");
let osu_ui_bak = osu_path.join("osu!ui.dll.bak");
let osu_gameplay_bak = osu_path.join("osu!gameplay.dll.bak");
let required_files = [&osu_ui, &osu_gameplay];
for file in &required_files {
if !file.exists() {
return Ok(true);
}
}
let bak_files = [&osu_ui_bak, &osu_gameplay_bak];
for bak in &bak_files {
if bak.exists() {
if let Err(e) = fs::remove_file(bak).await {
return Err(format!("Failed to delete {}: {}", bak.display(), e));
}
}
}
Ok(false)
}

View File

@ -4,11 +4,11 @@ use tauri::Manager;
pub mod commands; pub mod commands;
pub mod utils; pub mod utils;
use crate::commands::{ use crate::commands::{
download_ezpp_launcher_update_files, exit, find_osu_installation, get_beatmapsets_count, check_for_corruption, download_ezpp_launcher_update_files, exit, find_osu_installation,
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream, get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid, get_launcher_version,
get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser, get_osu_release_stream, get_osu_skin, get_osu_version, get_platform, get_skins_count,
replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values, is_osu_running, open_url_in_browser, replace_ui_files, run_osu, run_osu_updater,
valid_osu_folder, get_platform set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
}; };
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
@ -46,7 +46,8 @@ pub fn run() {
open_url_in_browser, open_url_in_browser,
get_launcher_version, get_launcher_version,
exit, exit,
get_platform get_platform,
check_for_corruption
]) ])
.plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())

View File

@ -114,3 +114,5 @@ export const isOsuRunning = async () => {
export const getLauncherVersion = async () => await invoke<string>('get_launcher_version'); export const getLauncherVersion = async () => await invoke<string>('get_launcher_version');
export const exit = async () => await invoke('exit'); export const exit = async () => await invoke('exit');
export const getPlatform = async () => await invoke<string>('get_platform'); export const getPlatform = async () => await invoke<string>('get_platform');
export const isOsuCorrupted = async (folder: string) =>
await invoke<boolean>('check_for_corruption', { folder });

View File

@ -84,6 +84,7 @@
getSkin, getSkin,
getSkinsCount, getSkinsCount,
getVersion, getVersion,
isOsuCorrupted,
isOsuRunning, isOsuRunning,
isValidOsuFolder, isValidOsuFolder,
replaceUIFiles, replaceUIFiles,
@ -221,7 +222,9 @@
} }
const releaseStream = await getReleaseStream(osuPath); const releaseStream = await getReleaseStream(osuPath);
let forceUpdate = releaseStream && releaseStream.toLowerCase() !== 'stable40'; const osuCorrupted = await isOsuCorrupted(osuPath);
let forceUpdate =
(releaseStream && releaseStream.toLowerCase() !== 'stable40') || osuCorrupted;
const versions = compareBuildNumbers($osuBuild, streamInfo); const versions = compareBuildNumbers($osuBuild, streamInfo);
if (versions > 0 || forceUpdate) { if (versions > 0 || forceUpdate) {