From 33942226e734161f585f86a4466c3fd08b9304dc Mon Sep 17 00:00:00 2001 From: yougotwill Date: Mon, 17 Feb 2025 11:41:27 +1100 Subject: [PATCH] fix: make sure to use updater prefix in all appropriate places makes it easier to debug --- ts/mains/main_node.ts | 5 ++++- ts/updater/index.ts | 10 +++++----- ts/updater/updater.ts | 28 +++++++++++++++++----------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 158f1bb6c..f29f24b2a 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -512,7 +512,10 @@ async function readyForUpdates() { await updater.start(getMainWindow, userConfig, i18n, logger); } catch (error) { const log = logger || console; - log.error('Error starting update checks:', error && error.stack ? error.stack : error); + log.error( + '[updater] Error starting update checks:', + error && error.stack ? error.stack : error + ); } } diff --git a/ts/updater/index.ts b/ts/updater/index.ts index dda7e979f..e49b0bfa4 100644 --- a/ts/updater/index.ts +++ b/ts/updater/index.ts @@ -14,24 +14,24 @@ export async function start( logger?: LoggerType | null ) { if (initialized) { - throw new Error('updater/start: Updates have already been initialized!'); + throw new Error('[updater] start: Updates have already been initialized!'); } if (!userConfig) { - throw new Error('updater/start: userConfig is needed!'); + throw new Error('[updater] start: userConfig is needed!'); } if (!i18n) { - throw new Error('updater/start: Must provide i18n!'); + throw new Error('[updater] start: Must provide i18n!'); } if (!logger) { - throw new Error('updater/start: Must provide logger!'); + throw new Error('[updater] start: Must provide logger!'); } initialized = true; localUserConfig = userConfig; // reused below if (autoUpdateDisabled()) { - logger.info('updater/start: Updates disabled - not starting new version checks'); + logger.info('[updater] start: Updates disabled - not starting new version checks'); return; } diff --git a/ts/updater/updater.ts b/ts/updater/updater.ts index f471b2339..d5d56b2a3 100644 --- a/ts/updater/updater.ts +++ b/ts/updater/updater.ts @@ -32,12 +32,12 @@ export async function start( logger: LoggerType ) { if (interval) { - logger.info('auto-update: Already running'); + logger.info('[updater] auto-update: Already running'); return; } - logger.info('auto-update: starting checks...'); + logger.info('[updater] auto-update: starting checks...'); autoUpdater.logger = logger; autoUpdater.autoDownload = false; @@ -46,7 +46,7 @@ export async function start( try { await checkForUpdates(getMainWindow, i18n, logger); } catch (error) { - logger.error('auto-update: error:', getPrintableError(error)); + logger.error('[updater] auto-update: error:', getPrintableError(error)); } }, UPDATER_INTERVAL_MS); // trigger and try to update every 10 minutes to let the file gets downloaded if we are updating stopped = false; @@ -56,11 +56,11 @@ export async function start( try { await checkForUpdates(getMainWindow, i18n, logger); } catch (error) { - logger.error('auto-update: error:', getPrintableError(error)); + logger.error('[updater] auto-update: error:', getPrintableError(error)); } }, 2 * 60 * 1000 - ); // we do checks from the file server every 1 minute. + ); // we do checks from the file server every 2 minutes. } export function stop() { @@ -84,7 +84,7 @@ async function checkForUpdates( const canUpdate = await canAutoUpdate(); logger.info('[updater] canUpdate', canUpdate); if (!canUpdate) { - logger.info('checkForUpdates canAutoUpdate false'); + logger.info('[updater] checkForUpdates canAutoUpdate false'); return; } @@ -108,7 +108,7 @@ async function checkForUpdates( logger.info('[updater] checkForUpdates isMoreRecent', isMoreRecent); if (!isMoreRecent) { logger.info( - `File server has no update so we are not looking for an update from github current:${currentVersion} fromFileServer:${latestVersionFromFsFromRenderer}` + `[updater] File server has no update so we are not looking for an update from github current:${currentVersion} fromFileServer:${latestVersionFromFsFromRenderer}` ); return; } @@ -136,7 +136,7 @@ async function checkForUpdates( const mainWindow = getMainWindow(); if (!mainWindow) { - console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); + console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset'); return; } logger.info('[updater] showing download dialog...'); @@ -153,7 +153,7 @@ async function checkForUpdates( } catch (error) { const mainWindow = getMainWindow(); if (!mainWindow) { - console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); + console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset'); return; } await showCannotUpdateDialog(mainWindow, i18n); @@ -161,7 +161,7 @@ async function checkForUpdates( } const window = getMainWindow(); if (!window) { - console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); + console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset'); return; } // Update downloaded successfully, we should ask the user to update @@ -182,13 +182,19 @@ async function checkForUpdates( function isUpdateAvailable(updateInfo: UpdateInfo): boolean { const latestVersion = parseVersion(updateInfo.version); if (!latestVersion) { + console.error( + '[updater] isUpdateAvailable could not parse latest version:', + updateInfo.version + ); return false; } // We need to convert this to string because typescript won't let us use types across submodules .... const currentVersion = autoUpdater.currentVersion.toString(); - return isVersionGreaterThan(latestVersion, currentVersion); + const latestIsNewer = isVersionGreaterThan(latestVersion, currentVersion); + console.log(`[updater] isUpdateAvailable latestIsNewer: ${latestIsNewer}`); + return latestIsNewer; } /*