Skip to content

Commit

Permalink
Remove old launcher installs after onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Aug 24, 2024
1 parent cf1103a commit 41d762f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
24 changes: 23 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ fn get_launch_argument() -> Option<String> {
return launch_arg.to_owned();
}

#[tauri::command(async)]
fn clean_up_old_install(yarg_folder: String, setlist_folder: String) -> Result<(), String> {
let mut stable_old = PathBuf::from(&yarg_folder);
stable_old.push("stable");
clear_folder(&stable_old)?;
let _ = fs::remove_dir(&stable_old);

let mut nightly_old = PathBuf::from(&yarg_folder);
nightly_old.push("nightly");
clear_folder(&nightly_old)?;
let _ = fs::remove_dir(&nightly_old);

let mut setlist_old = PathBuf::from(&setlist_folder);
setlist_old.push("official");
clear_folder(&setlist_old)?;
let _ = fs::remove_dir(&setlist_old);

Ok(())
}

fn main() {
let args = CommandLineArgs::parse();

Expand All @@ -242,7 +262,9 @@ fn main() {
launch_profile,
open_folder_profile,

get_launch_argument
get_launch_argument,

clean_up_old_install
])
.setup(|app| {
// Show the window's shadow
Expand Down
2 changes: 1 addition & 1 deletion src/components/Onboarding/Onboarding.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
align-self: stretch;
}

.offline {
.center {
height: 100%;

display: flex;
Expand Down
27 changes: 22 additions & 5 deletions src/components/Onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Onboarding: React.FC<Props> = (props: Props) => {

if (offlineStatus.isOffline) {
return <main className={styles.mainContainer}>
<div className={styles.offline}>
<div className={styles.center}>
<span>
You&apos;re offline! Please connect to the internet and restart the launcher to
finish the launcher onboarding process.
Expand Down Expand Up @@ -75,6 +75,16 @@ const Onboarding: React.FC<Props> = (props: Props) => {
await directories.setDirs(downloadLocation);
directories = useDirectories.getState();

// If the user has old stuff installed, remove those
try {
await invoke("clean_up_old_install", {
yargFolder: directories.customDirs?.yargFolder,
setlistFolder: directories.customDirs?.setlistFolder
});
} catch {
// Ignore
}

for (const url of profileUrls) {
const uuid = await useProfileStore.getState().activateProfile(url);
if (uuid === undefined) {
Expand All @@ -94,8 +104,8 @@ const Onboarding: React.FC<Props> = (props: Props) => {
}

return <main className={styles.mainContainer}>
<div className={styles.container}>
{!loading && <>
{!loading &&
<div className={styles.container}>
<OnboardingSidebar onboardingStep={step} />
<div className={styles.content}>
<div className={styles.contentContainer}>
Expand Down Expand Up @@ -136,8 +146,15 @@ const Onboarding: React.FC<Props> = (props: Props) => {
</div>
</div>
</div>
</>}
</div>
</div>
}
{loading &&
<div className={styles.center}>
<span>
Loading, please wait...
</span>
</div>
}
</main>;
};

Expand Down

0 comments on commit 41d762f

Please sign in to comment.