SDA-4489 - Fix issue related to different env (#2137)

This commit is contained in:
Kiran Niranjan
2024-04-25 13:39:10 +05:30
committed by GitHub
parent b3ea7c258a
commit 3b39725f9d
2 changed files with 16 additions and 13 deletions

View File

@@ -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<string | void> => {
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) => {

View File

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