Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate successful install progression and handle file not found errors #583

Merged
merged 7 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src-tauri/src/commands/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,38 @@ pub async fn uninstall_game(
.join(&game_name)
.join("data");

std::fs::remove_dir_all(data_folder.join("decompiler_out"))?;
std::fs::remove_dir_all(data_folder.join("iso_data"))?;
std::fs::remove_dir_all(data_folder.join("out"))?;
match std::fs::remove_dir_all(data_folder.join("decompiler_out")) {
Ok(_) => Ok(()),
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => Ok(()),
_ => {
log::error!("Failed to delete directory: {:?}", e);
Err(e)
}
},
}?;

match std::fs::remove_dir_all(data_folder.join("iso_data")) {
Ok(_) => Ok(()),
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => Ok(()),
_ => {
log::error!("Failed to delete directory: {:?}", e);
Err(e)
}
},
}?;

match std::fs::remove_dir_all(data_folder.join("out")) {
Ok(_) => Ok(()),
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => Ok(()),
_ => {
log::error!("Failed to delete directory: {:?}", e);
Err(e)
}
},
}?;

config_lock
.update_installed_game_version(&game_name, false)
Expand Down
20 changes: 5 additions & 15 deletions src/components/games/job/GameJob.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
const dispatch = createEventDispatcher();
let installationError: string | undefined | null = undefined;

$: if ($progressTracker.overallStatus === "success") {
dispatch("jobFinished");
}

async function setupDecompileJob() {
installationError = undefined;
progressTracker.init([
Expand Down Expand Up @@ -470,27 +474,13 @@
await setupCompileModJob();
}
});

function dispatchCompleteJob() {
dispatch("jobFinished");
}
</script>

<div class="flex flex-col justify-content">
<Progress />
<LogViewer />
</div>
{#if $progressTracker.overallStatus === "success"}
<div class="flex flex-col justify-end items-end mt-auto">
<div class="flex flex-row gap-2">
<Button
class="border-solid border-2 border-slate-900 rounded bg-slate-900 hover:bg-slate-800 text-sm text-white font-semibold px-5 py-2"
on:click={async () => dispatchCompleteJob()}
>{$_("setup_button_continue")}</Button
>
</div>
</div>
{:else if $progressTracker.overallStatus === "failed"}
{#if $progressTracker.overallStatus === "failed"}
<div class="flex flex-col mt-auto">
<div class="flex flex-row gap-2">
<Alert color="red" class="dark:bg-slate-900 flex-grow">
Expand Down
14 changes: 2 additions & 12 deletions src/components/games/setup/GameSetup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
}
}

async function dispatchSetupEvent() {
$: if ($progressTracker.overallStatus === "success") {
dispatch("change");
}
</script>
Expand All @@ -129,17 +129,7 @@
<Progress />
<LogViewer />
</div>
{#if $progressTracker.overallStatus === "success"}
<div class="flex flex-col justify-end items-end mt-auto">
<div class="flex flex-row gap-2">
<Button
class="border-solid border-2 border-slate-900 rounded bg-slate-900 hover:bg-slate-800 text-sm text-white font-semibold px-5 py-2"
on:click={async () => await dispatchSetupEvent()}
>{$_("setup_button_continue")}</Button
>
</div>
</div>
{:else if $progressTracker.overallStatus === "failed"}
{#if $progressTracker.overallStatus === "failed"}
<div class="flex flex-col mt-auto">
<div class="flex flex-row gap-2">
<Alert
Expand Down
Loading