chore: check for missing files on start
This commit is contained in:
@@ -638,4 +638,33 @@ pub fn exit(app: AppHandle) {
|
||||
#[tauri::command]
|
||||
pub fn get_platform() -> 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)
|
||||
}
|
||||
|
@@ -4,11 +4,11 @@ use tauri::Manager;
|
||||
pub mod commands;
|
||||
pub mod utils;
|
||||
use crate::commands::{
|
||||
download_ezpp_launcher_update_files, exit, find_osu_installation, get_beatmapsets_count,
|
||||
get_ezpp_launcher_update_files, get_hwid, get_launcher_version, get_osu_release_stream,
|
||||
get_osu_skin, get_osu_version, get_skins_count, is_osu_running, open_url_in_browser,
|
||||
replace_ui_files, run_osu, run_osu_updater, set_osu_config_values, set_osu_user_config_values,
|
||||
valid_osu_folder, get_platform
|
||||
check_for_corruption, download_ezpp_launcher_update_files, exit, find_osu_installation,
|
||||
get_beatmapsets_count, get_ezpp_launcher_update_files, get_hwid, get_launcher_version,
|
||||
get_osu_release_stream, get_osu_skin, get_osu_version, get_platform, get_skins_count,
|
||||
is_osu_running, open_url_in_browser, replace_ui_files, run_osu, run_osu_updater,
|
||||
set_osu_config_values, set_osu_user_config_values, valid_osu_folder,
|
||||
};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -46,7 +46,8 @@ pub fn run() {
|
||||
open_url_in_browser,
|
||||
get_launcher_version,
|
||||
exit,
|
||||
get_platform
|
||||
get_platform,
|
||||
check_for_corruption
|
||||
])
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
Reference in New Issue
Block a user