fix: make sure to use updater prefix in all appropriate places

makes it easier to debug
pull/3281/head
yougotwill 3 months ago
parent 4e1ba97763
commit 33942226e7

@ -512,7 +512,10 @@ async function readyForUpdates() {
await updater.start(getMainWindow, userConfig, i18n, logger); await updater.start(getMainWindow, userConfig, i18n, logger);
} catch (error) { } catch (error) {
const log = logger || console; 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
);
} }
} }

@ -14,24 +14,24 @@ export async function start(
logger?: LoggerType | null logger?: LoggerType | null
) { ) {
if (initialized) { if (initialized) {
throw new Error('updater/start: Updates have already been initialized!'); throw new Error('[updater] start: Updates have already been initialized!');
} }
if (!userConfig) { if (!userConfig) {
throw new Error('updater/start: userConfig is needed!'); throw new Error('[updater] start: userConfig is needed!');
} }
if (!i18n) { if (!i18n) {
throw new Error('updater/start: Must provide i18n!'); throw new Error('[updater] start: Must provide i18n!');
} }
if (!logger) { if (!logger) {
throw new Error('updater/start: Must provide logger!'); throw new Error('[updater] start: Must provide logger!');
} }
initialized = true; initialized = true;
localUserConfig = userConfig; // reused below localUserConfig = userConfig; // reused below
if (autoUpdateDisabled()) { 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; return;
} }

@ -32,12 +32,12 @@ export async function start(
logger: LoggerType logger: LoggerType
) { ) {
if (interval) { if (interval) {
logger.info('auto-update: Already running'); logger.info('[updater] auto-update: Already running');
return; return;
} }
logger.info('auto-update: starting checks...'); logger.info('[updater] auto-update: starting checks...');
autoUpdater.logger = logger; autoUpdater.logger = logger;
autoUpdater.autoDownload = false; autoUpdater.autoDownload = false;
@ -46,7 +46,7 @@ export async function start(
try { try {
await checkForUpdates(getMainWindow, i18n, logger); await checkForUpdates(getMainWindow, i18n, logger);
} catch (error) { } 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 }, UPDATER_INTERVAL_MS); // trigger and try to update every 10 minutes to let the file gets downloaded if we are updating
stopped = false; stopped = false;
@ -56,11 +56,11 @@ export async function start(
try { try {
await checkForUpdates(getMainWindow, i18n, logger); await checkForUpdates(getMainWindow, i18n, logger);
} catch (error) { } catch (error) {
logger.error('auto-update: error:', getPrintableError(error)); logger.error('[updater] auto-update: error:', getPrintableError(error));
} }
}, },
2 * 60 * 1000 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() { export function stop() {
@ -84,7 +84,7 @@ async function checkForUpdates(
const canUpdate = await canAutoUpdate(); const canUpdate = await canAutoUpdate();
logger.info('[updater] canUpdate', canUpdate); logger.info('[updater] canUpdate', canUpdate);
if (!canUpdate) { if (!canUpdate) {
logger.info('checkForUpdates canAutoUpdate false'); logger.info('[updater] checkForUpdates canAutoUpdate false');
return; return;
} }
@ -108,7 +108,7 @@ async function checkForUpdates(
logger.info('[updater] checkForUpdates isMoreRecent', isMoreRecent); logger.info('[updater] checkForUpdates isMoreRecent', isMoreRecent);
if (!isMoreRecent) { if (!isMoreRecent) {
logger.info( 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; return;
} }
@ -136,7 +136,7 @@ async function checkForUpdates(
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
if (!mainWindow) { if (!mainWindow) {
console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset');
return; return;
} }
logger.info('[updater] showing download dialog...'); logger.info('[updater] showing download dialog...');
@ -153,7 +153,7 @@ async function checkForUpdates(
} catch (error) { } catch (error) {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
if (!mainWindow) { if (!mainWindow) {
console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset');
return; return;
} }
await showCannotUpdateDialog(mainWindow, i18n); await showCannotUpdateDialog(mainWindow, i18n);
@ -161,7 +161,7 @@ async function checkForUpdates(
} }
const window = getMainWindow(); const window = getMainWindow();
if (!window) { if (!window) {
console.error('cannot showDownloadUpdateDialog, mainWindow is unset'); console.error('[updater] cannot showDownloadUpdateDialog, mainWindow is unset');
return; return;
} }
// Update downloaded successfully, we should ask the user to update // Update downloaded successfully, we should ask the user to update
@ -182,13 +182,19 @@ async function checkForUpdates(
function isUpdateAvailable(updateInfo: UpdateInfo): boolean { function isUpdateAvailable(updateInfo: UpdateInfo): boolean {
const latestVersion = parseVersion(updateInfo.version); const latestVersion = parseVersion(updateInfo.version);
if (!latestVersion) { if (!latestVersion) {
console.error(
'[updater] isUpdateAvailable could not parse latest version:',
updateInfo.version
);
return false; return false;
} }
// We need to convert this to string because typescript won't let us use types across submodules .... // We need to convert this to string because typescript won't let us use types across submodules ....
const currentVersion = autoUpdater.currentVersion.toString(); const currentVersion = autoUpdater.currentVersion.toString();
return isVersionGreaterThan(latestVersion, currentVersion); const latestIsNewer = isVersionGreaterThan(latestVersion, currentVersion);
console.log(`[updater] isUpdateAvailable latestIsNewer: ${latestIsNewer}`);
return latestIsNewer;
} }
/* /*

Loading…
Cancel
Save