From efaab720b6637ad90bde18d63d278881ed70ea96 Mon Sep 17 00:00:00 2001 From: Nikhil Narayana Date: Sun, 15 Sep 2024 19:34:04 -0700 Subject: [PATCH] refactor: remove temp files on startup --- src/dolphin/install/ishiiruka_installation.ts | 3 --- src/dolphin/install/mainline_installation.ts | 3 --- src/renderer/lib/hooks/use_app.ts | 13 +++++++++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/dolphin/install/ishiiruka_installation.ts b/src/dolphin/install/ishiiruka_installation.ts index d8e1c281d..63a101eed 100644 --- a/src/dolphin/install/ishiiruka_installation.ts +++ b/src/dolphin/install/ishiiruka_installation.ts @@ -309,8 +309,5 @@ export class IshiirukaDolphinInstallation implements DolphinInstallation { ); } } - await fs.remove(assetPath).catch((err) => { - log.error(`Could not delete dolphin asset: ${err}`); - }); } } diff --git a/src/dolphin/install/mainline_installation.ts b/src/dolphin/install/mainline_installation.ts index 997098ca8..6c45105ac 100644 --- a/src/dolphin/install/mainline_installation.ts +++ b/src/dolphin/install/mainline_installation.ts @@ -305,8 +305,5 @@ export class MainlineDolphinInstallation implements DolphinInstallation { ); } } - await fs.remove(assetPath).catch((err) => { - log.error(`Could not delete dolphin asset: ${err}`); - }); } } diff --git a/src/renderer/lib/hooks/use_app.ts b/src/renderer/lib/hooks/use_app.ts index 18ab2e267..5c95ecf54 100644 --- a/src/renderer/lib/hooks/use_app.ts +++ b/src/renderer/lib/hooks/use_app.ts @@ -92,6 +92,19 @@ export const useAppInitialization = () => { // Check if there is an update to the launcher promises.push(window.electron.common.checkForAppUpdates()); + // Remove any temp files + promises.push( + (async () => { + window.electron.common.clearTempFolder().catch((err) => { + // silently fail since this isn't a critical issue + log.error( + `Could not clear temp folder on startup due to: + ${err instanceof Error ? err.message : JSON.stringify(err)}`, + ); + }); + })(), + ); + // Wait for all the promises to complete before completing try { await Promise.all(promises);