From 52f00c9249d8a671fc9168030a9c0d6eb36c69d8 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:32:22 -0700 Subject: [PATCH] feat: clear misc files when switching --- src/main.rs | 1 + src/osu_util.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index db9538e..d7b85ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -189,5 +189,6 @@ fn switch(ctx: &Context) { .expect("Failed to save switcher config"); } + osu_util::clear_misc(&*osu_dir); osu_util::restart_osu(&osu_exe, &server); } diff --git a/src/osu_util.rs b/src/osu_util.rs index 32b569e..786cf4b 100644 --- a/src/osu_util.rs +++ b/src/osu_util.rs @@ -34,3 +34,16 @@ pub fn restart_osu(osu_exe: &String, server: &String) { .spawn() .expect("Failed to start osu"); } + +/// Clear miscellaneous files that might be an issue when relaunching +pub fn clear_misc(osu_dir: &str) { + // If this is present, it causes osu! to relaunch and repair itself, which doesn't preserve -devserver + let force_update_file = format!("{osu_dir}/.require_update"); + + // I have no clue what this contains, but I have heard about this potentially containing anti-multi-accounting + // data, which might interfere with switching accounts across servers. Just to be safe, wipe it regardless. + let osu_auth_logs = format!("{osu_dir}/Logs/osu!auth.log"); + + let _ = std::fs::remove_file(force_update_file.as_str()); + let _ = std::fs::remove_file(osu_auth_logs.as_str()); +}