diff --git a/desktop/main.ts b/desktop/main.ts index 2b296d84f6a3..1c5b6cfcb8a0 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -212,6 +212,9 @@ const showKeyboardShortcutsPage = (browserWindow: BrowserWindow) => { const electronUpdater = (browserWindow: BrowserWindow): PlatformSpecificUpdater => ({ init: () => { autoUpdater.on(ELECTRON_EVENTS.UPDATE_DOWNLOADED, (info) => { + // eslint-disable-next-line no-console + console.group('[dev] ELECTRON_EVENTS.UPDATE_DOWNLOADED'); + console.debug('[dev] info:', info); const systemMenu = Menu.getApplicationMenu(); const updateMenuItem = systemMenu?.getMenuItemById(`update`); const checkForUpdatesMenuItem = systemMenu?.getMenuItemById(`checkForUpdates`); @@ -227,15 +230,39 @@ const electronUpdater = (browserWindow: BrowserWindow): PlatformSpecificUpdater if (browserWindow.isVisible() && !isSilentUpdating) { browserWindow.webContents.send(ELECTRON_EVENTS.UPDATE_DOWNLOADED, info.version); } else { - quitAndInstallWithUpdate(); + console.debug('[dev] else'); + + autoUpdater + .checkForUpdates() + .then((result) => { + console.debug('[dev] result', result); + if (result?.updateInfo.version === downloadedVersion) { + console.debug('[dev] if - versions match, installing'); + quitAndInstallWithUpdate(); + } else { + console.debug('[dev] else - downloading new update'); + return autoUpdater.downloadUpdate().then(() => { + console.debug('[dev] download complete, installing'); + quitAndInstallWithUpdate(); + }); + } + }) + .catch((error) => { + console.debug('[dev] error', error); + log.error('Error during update check or download:', error); + }); } + // eslint-disable-next-line no-console + console.groupEnd(); }); ipcMain.on(ELECTRON_EVENTS.START_UPDATE, quitAndInstallWithUpdate); autoUpdater.checkForUpdates(); }, update: () => { - autoUpdater.checkForUpdates(); + autoUpdater.checkForUpdates().then((result) => { + console.debug('[dev] update result', result); + }); }, });