diff --git a/src/app/auto-update-handler.ts b/src/app/auto-update-handler.ts index 0794ecf9..0c078510 100644 --- a/src/app/auto-update-handler.ts +++ b/src/app/auto-update-handler.ts @@ -95,6 +95,10 @@ export class AutoUpdate { logger.info( 'auto-update-handler: update downloaded and isForceUpdate', ); + // Handle update and restart for macOS + if (isMac) { + windowHandler.setIsAutoUpdating(true); + } this.autoUpdater?.quitAndInstall(); return; } @@ -124,7 +128,7 @@ export class AutoUpdate { return; } - const updaterFilePath = path.join(cacheDir, 'symphony-updater/pending'); + const updaterFilePath = path.join(cacheDir, 'symphony-updater', 'pending'); if (!fs.existsSync(updaterFilePath)) { logger.info( 'auto-update-handler: Updater directory not found, skipping forced auto-update.', @@ -156,8 +160,9 @@ export class AutoUpdate { return; } - const hasPendingInstaller = files.some((item) => - item.includes(latestVersionFromServer), + const hasPendingInstaller = files.some( + (item) => + item.includes(latestVersionFromServer) && !item.startsWith('temp'), ); if (hasPendingInstaller) { logger.info('auto-update-handler: latest version found force installing'); @@ -263,16 +268,12 @@ export class AutoUpdate { }; private fetchLatestVersion = async (): Promise => { - await this.setAutoUpdateChannel(); - return new Promise((resolve) => { - const url = this.getUpdateUrl(); - const { autoUpdateChannel } = config.getConfigFields([ - 'autoUpdateChannel', - ]); - const endpoint = `${url}/${autoUpdateChannel}.yml`; + return new Promise(async (resolve) => { + const opts = await this.getGenericServerOptions(); + const url = opts.channel ? `${opts.url}/${opts.channel}.yml` : opts.url; logger.info( 'auto-update-handler: fetching latest version info from', - endpoint, + url, ); const controller = new AbortController(); const signal = controller.signal; @@ -280,7 +281,7 @@ export class AutoUpdate { () => controller.abort(), FORCE_UPDATE_TIMEOUT, ); - fetch(endpoint, { signal }) + fetch(url, { signal }) .then((res) => res.blob()) .then((blob) => blob.text()) .then(async (response) => { @@ -293,6 +294,8 @@ export class AutoUpdate { if (match && match.length) { logger.info('auto-update-handler: version found', match[1]); resolve(match[1]); + } else { + resolve(); } }) .catch(async (error) => { diff --git a/src/app/main.ts b/src/app/main.ts index c448f821..80b554f5 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -83,7 +83,6 @@ const startApplication = async () => { // Validate user config before starting the application await config.initializeUserConfig(); await config.readUserConfig(); - await autoUpdate.performForcedAutoUpdate(); await config.checkFirstTimeLaunch(); const isFirstTimeLaunch = config.isFirstTimeLaunch(); if (isFirstTimeLaunch) { @@ -109,6 +108,7 @@ const startApplication = async () => { // Picks global config values and updates them in the user config await config.updateUserConfigOnStart(); setSessionProperties(); + await autoUpdate.performForcedAutoUpdate(); await windowHandler.createApplication(); logger.info(`main: created application`); };