Skip to content

Commit ebe36a2

Browse files
committed
Refactor auto updater configuration and enhance update handling
1 parent dd846c7 commit ebe36a2

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

web/electron/main/updates.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function canUseAutoUpdater() {
309309
}
310310

311311
function configureAutoUpdater() {
312-
if (updaterConfigured) return
312+
if (updaterConfigured) return autoUpdater
313313
updaterConfigured = true
314314
autoUpdater.autoDownload = true
315315
autoUpdater.autoInstallOnAppQuit = true
@@ -378,6 +378,8 @@ function configureAutoUpdater() {
378378
}
379379
emitUpdateState()
380380
})
381+
382+
return autoUpdater
381383
}
382384

383385
async function enrichFromGithub(version: string, channel: UpdateChannel) {
@@ -489,11 +491,13 @@ export async function checkForUpdates(
489491

490492
if (canUseAutoUpdater()) {
491493
try {
492-
await checkWithAutoUpdater(version, channel)
493-
await enrichFromGithub(version, channel)
494-
lastError = undefined
495-
emitUpdateState()
496-
return snapshot()
494+
const usedUpdater = await checkWithAutoUpdater(version, channel)
495+
if (usedUpdater) {
496+
await enrichFromGithub(version, channel)
497+
lastError = undefined
498+
emitUpdateState()
499+
return snapshot()
500+
}
497501
} catch (error) {
498502
lastError = error instanceof Error ? error.message : 'update_check_failed'
499503
}

web/tsconfig.node.tsbuildinfo

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

web/vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ export default defineConfig(({ command }) => {
2727
electronSimple({
2828
main: {
2929
input: 'electron/main/index.ts',
30+
bundleDeps: true,
3031
options: {
3132
build: {
3233
sourcemap,
3334
minify: isBuild,
3435
outDir: 'dist-electron/main',
3536
rolldownOptions: {
36-
external: ['electron', 'electron-updater'],
37+
external: ['electron'],
3738
},
3839
},
3940
},

0 commit comments

Comments
 (0)