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

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

@ -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
);
}
}

@ -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;
}

@ -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;
}
/*

Loading…
Cancel
Save