diff --git a/electron/main/index.ts b/electron/main/index.ts index 2eeaaf459..074efe21b 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -172,8 +172,8 @@ ipcMain.on(SHUTDOWN_FINISHED, () => { ipcMain.on(CLEAR_WALLET_FILES, () => { walletManager.setRelaunch(true) walletManager.setForceQuit(true) - walletManager.clearWalletFiles(SHEIKAH_PATH) - win.webContents.send(SHUTDOWN) + walletManager.setClearWalletFiles(true) + walletManager.killWalletProcess() }) app.on('activate', () => { diff --git a/electron/walletManager.ts b/electron/walletManager.ts index a3b99a3bd..60d740fbe 100644 --- a/electron/walletManager.ts +++ b/electron/walletManager.ts @@ -59,6 +59,7 @@ interface GithubTagInfo { export class WalletManager { public webContents: Electron.WebContents | null public isUpdating: boolean = false + public clearFiles: boolean = false public relaunch: boolean = false public forceQuit: boolean = false public walletProcess: cp.ChildProcessWithoutNullStreams | null = null @@ -158,6 +159,10 @@ export class WalletManager { this.forceQuit = status } + public setClearWalletFiles(status: boolean) { + this.clearFiles = status + } + // Download a wallet release from the url specified public async downloadWallet(actions: Actions, releaseUrl: string) { console.info( @@ -179,7 +184,6 @@ export class WalletManager { } public clearWalletFiles(pathToClear: string) { - this.killWalletProcess() console.log('Exists path?', fs.existsSync(pathToClear)) if (fs.existsSync(pathToClear)) { fs.rmSync(pathToClear, { recursive: true, force: true }) @@ -312,6 +316,9 @@ export class WalletManager { this.walletProcess.on('exit', () => { console.log('FORCE QUIT?', this.forceQuit) console.log('Relaunch?', this.relaunch) + if (this.clearFiles) { + this.clearWalletFiles(SHEIKAH_PATH) + } if (this.forceQuit) { if (this.relaunch) { actions.relaunch()