From fc0c34d9748aa6d6fc8630144c836ece68c3d4e8 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Tue, 24 Sep 2024 19:57:49 +0800 Subject: [PATCH] fix portable updater --- src/main/resolve/autoUpdater.ts | 16 ++++++++-------- src/main/utils/init.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resolve/autoUpdater.ts b/src/main/resolve/autoUpdater.ts index ab76312..b59da54 100644 --- a/src/main/resolve/autoUpdater.ts +++ b/src/main/resolve/autoUpdater.ts @@ -74,14 +74,14 @@ export async function downloadAndInstallUpdate(version: string): Promise { }).unref() } if (file.endsWith('.7z')) { - spawn( - path.join(resourcesFilesDir(), '7za.exe'), - ['x', `-o"${exeDir()}"`, '-y', path.join(dataDir(), file)], - { - shell: true, - detached: true - } - ).unref() + await writeFile( + path.join(exeDir(), 'install.ps1'), + `& "${path.join(resourcesFilesDir(), '7za.exe')}" x -o"${exeDir()}" -y "${path.join(dataDir(), file)}"; Start-Process -FilePath "${exePath()}"` + ) + spawn('powershell', ['-File', `"${path.join(exeDir(), 'install.ps1')}"`], { + shell: true, + detached: true + }).unref() app.quit() } if (file.endsWith('.dmg')) { diff --git a/src/main/utils/init.ts b/src/main/utils/init.ts index 453f9c9..b71d8d3 100644 --- a/src/main/utils/init.ts +++ b/src/main/utils/init.ts @@ -105,7 +105,7 @@ async function cleanup(): Promise { // update cache const files = await readdir(dataDir()) for (const file of files) { - if (file.endsWith('.exe') || file.endsWith('.dmg')) { + if (file.endsWith('.exe') || file.endsWith('.dmg') || file.endsWith('.7z')) { try { await rm(path.join(dataDir(), file)) } catch {