Skip to content

Commit b4c3436

Browse files
Merge pull request #62 from lightningpixel/release/v0.2.1
Release/v0.2.1
2 parents ba46927 + 7eda270 commit b4c3436

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

electron/main/ipc-handlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,9 @@ export function setupIpcHandlers(pythonBridge: PythonBridge, getWindow: WindowGe
574574
})
575575

576576
ipcMain.handle('updater:quitAndInstall', () => {
577-
autoUpdater.quitAndInstall(false, true)
577+
app.removeAllListeners('window-all-closed')
578+
BrowserWindow.getAllWindows().forEach(w => w.destroy())
579+
autoUpdater.quitAndInstall(true, true)
578580
})
579581

580582
// Update FastAPI paths at runtime (without restarting)

electron/main/updater.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
import { app, BrowserWindow } from 'electron'
22
import { autoUpdater } from 'electron-updater'
3+
import { existsSync, rmSync, writeFileSync, readFileSync } from 'fs'
4+
import { join } from 'path'
35
import { logger } from './logger'
46

57
type WindowGetter = () => BrowserWindow | null
68

9+
function pendingFilePath(): string {
10+
return join(app.getPath('userData'), '.last-update-installer')
11+
}
12+
13+
function cleanupLastInstaller(): void {
14+
const marker = pendingFilePath()
15+
if (!existsSync(marker)) return
16+
try {
17+
const installerPath = readFileSync(marker, 'utf-8').trim()
18+
if (existsSync(installerPath)) {
19+
rmSync(installerPath)
20+
logger.info(`[updater] Cleaned up installer: ${installerPath}`)
21+
}
22+
rmSync(marker)
23+
} catch {}
24+
}
25+
726
export function initAutoUpdater(getWindow: WindowGetter): void {
27+
cleanupLastInstaller()
28+
829
// eslint-disable-next-line @typescript-eslint/no-explicit-any
930
autoUpdater.logger = logger as any
1031
autoUpdater.autoDownload = false
@@ -30,6 +51,9 @@ export function initAutoUpdater(getWindow: WindowGetter): void {
3051

3152
autoUpdater.on('update-downloaded', (info) => {
3253
logger.info(`[updater] Patch update ${info.version} downloaded — showing badge`)
54+
try {
55+
writeFileSync(pendingFilePath(), info.downloadedFile, 'utf-8')
56+
} catch {}
3357
getWindow()?.webContents.send('updater:patch-ready', { version: info.version })
3458
})
3559

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
},
7575
"win": {
7676
"target": "nsis",
77+
"artifactName": "${productName}-Setup-${version}.${ext}",
7778
"icon": "resources/icons/icon.ico",
7879
"extraResources": [
7980
{

0 commit comments

Comments
 (0)