Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion electron/main/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ export function setupIpcHandlers(pythonBridge: PythonBridge, getWindow: WindowGe
})

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

// Update FastAPI paths at runtime (without restarting)
Expand Down
24 changes: 24 additions & 0 deletions electron/main/updater.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import { app, BrowserWindow } from 'electron'
import { autoUpdater } from 'electron-updater'
import { existsSync, rmSync, writeFileSync, readFileSync } from 'fs'
import { join } from 'path'
import { logger } from './logger'

type WindowGetter = () => BrowserWindow | null

function pendingFilePath(): string {
return join(app.getPath('userData'), '.last-update-installer')
}

function cleanupLastInstaller(): void {
const marker = pendingFilePath()
if (!existsSync(marker)) return
try {
const installerPath = readFileSync(marker, 'utf-8').trim()
if (existsSync(installerPath)) {
rmSync(installerPath)
logger.info(`[updater] Cleaned up installer: ${installerPath}`)
}
rmSync(marker)
} catch {}
}

export function initAutoUpdater(getWindow: WindowGetter): void {
cleanupLastInstaller()

// eslint-disable-next-line @typescript-eslint/no-explicit-any
autoUpdater.logger = logger as any
autoUpdater.autoDownload = false
Expand All @@ -30,6 +51,9 @@ export function initAutoUpdater(getWindow: WindowGetter): void {

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

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
},
"win": {
"target": "nsis",
"artifactName": "${productName}-Setup-${version}.${ext}",
"icon": "resources/icons/icon.ico",
"extraResources": [
{
Expand Down
Loading