automate successful install progression and handle file not found errors (#583)
Some checks are pending
🔨 Build / App (macos-12) (push) Waiting to run
🔨 Build / App (ubuntu-20.04) (push) Waiting to run
🔨 Build / App (windows-latest) (push) Waiting to run
📝 Linter / Frontend (push) Waiting to run
📝 Linter / Backend Formatting (push) Waiting to run
📝 Linter / Backend Linter (push) Waiting to run
🧪 Tests / Frontend (push) Waiting to run

- automatically progress app after successful install. reduces friction
leading to a better UX.
- ignore file not found error when uninstalling. after deleted my
`iso_data` directory I was unable to successfully uninstall the game
because the `?` unwrap would propagate the file not found error. Since
our intention is to delete these files, if they are not found we should
ignore the error and continue deleting the rest.
This commit is contained in:
tripp 2024-10-04 12:03:10 -04:00 committed by GitHub
parent 128df5637e
commit 6ea179ae98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 30 deletions

View file

@ -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)

View file

@ -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([
@ -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">

View file

@ -117,7 +117,7 @@
}
}
async function dispatchSetupEvent() {
$: if ($progressTracker.overallStatus === "success") {
dispatch("change");
}
</script>
@ -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