From 403a5a1e378d900db482a9079693656e3c56e756 Mon Sep 17 00:00:00 2001 From: yougotwill Date: Fri, 7 Mar 2025 15:48:35 +1100 Subject: [PATCH] refactor: revert app restart behaviour after an update is downloaded --- ts/updater/updater.ts | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/ts/updater/updater.ts b/ts/updater/updater.ts index 62d18841e..37c523536 100644 --- a/ts/updater/updater.ts +++ b/ts/updater/updater.ts @@ -1,12 +1,7 @@ /* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable no-console */ import { app, type BrowserWindow } from 'electron'; -import { - autoUpdater, - DOWNLOAD_PROGRESS, - UPDATE_DOWNLOADED, - type UpdateInfo, -} from 'electron-updater'; +import { autoUpdater, DOWNLOAD_PROGRESS, type UpdateInfo } from 'electron-updater'; import * as fs from 'fs-extra'; import * as path from 'path'; import { gt as isVersionGreaterThan, parse as parseVersion } from 'semver'; @@ -36,18 +31,6 @@ autoUpdater.on(DOWNLOAD_PROGRESS, eventDownloadProgress => { ); }); -autoUpdater.on(UPDATE_DOWNLOADED, () => { - isUpdating = true; - console.log('[updater] update downloaded'); - // https://github.com/electron-userland/electron-builder/issues/6058#issuecomment-1130344017 - setTimeout(() => { - console.info('[updater] calling quitAndInstall...'); - autoUpdater.quitAndInstall(); - app.exit(); - isUpdating = false; - }, 1000); -}); - export async function start( getMainWindow: () => BrowserWindow | null, i18n: SetupI18nReturnType, @@ -208,8 +191,9 @@ async function checkForUpdates( return; } - logger.info('[updater] calling windowMarkShouldQuit...'); + logger.info('[updater] calling windowMarkShouldQuit then quitAndInstall...'); windowMarkShouldQuit(); + autoUpdater.quitAndInstall(); } finally { isUpdating = false; }