Revert SDA-4489 (#2140)

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

This reverts commit 3b39725f9d.

* Revert "SDA-4489 - Invoke check for update & download before force install (#2132)"

This reverts commit b3ea7c258a.

* Revert "SDA-4489 - Fix wrong import (#2129)"

This reverts commit 6e82aca630.

* Revert "SDA-4489 (Force auto update) (#2128)"

This reverts commit 68194f4a4c.
This commit is contained in:
Kiran Niranjan 2024-05-03 08:32:11 +05:30 committed by GitHub
parent 020cd05eab
commit ce72411ae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 176 deletions

52
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "symphony", "name": "symphony",
"version": "24.6.0", "version": "24.4.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "symphony", "name": "symphony",
"version": "24.6.0", "version": "24.4.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
@ -40,7 +40,7 @@
"builder-util-runtime": "^9.0.3", "builder-util-runtime": "^9.0.3",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"del": "3.0.0", "del": "3.0.0",
"electron": "29.1.5", "electron": "^28.2.0",
"electron-builder": "^24.13.2", "electron-builder": "^24.13.2",
"electron-icon-maker": "0.0.5", "electron-icon-maker": "0.0.5",
"electron-osx-sign": "^0.6.0", "electron-osx-sign": "^0.6.0",
@ -6337,14 +6337,14 @@
} }
}, },
"node_modules/electron": { "node_modules/electron": {
"version": "29.1.5", "version": "28.2.0",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-29.1.5.tgz", "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.2.0.tgz",
"integrity": "sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==", "integrity": "sha512-22SylXQQ9IHtwLw4D+Z4Si7OUpeDtpHfJVTjy3yv53iLg5zJKKPOCWT4ZwgYGHQZ0eldyBrYBHF/P9FPd2CcVQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@electron/get": "^2.0.0", "@electron/get": "^2.0.0",
"@types/node": "^20.9.0", "@types/node": "^18.11.18",
"extract-zip": "^2.0.1" "extract-zip": "^2.0.1"
}, },
"bin": { "bin": {
@ -6788,15 +6788,6 @@
"node": ">= 10.0.0" "node": ">= 10.0.0"
} }
}, },
"node_modules/electron/node_modules/@types/node": {
"version": "20.12.6",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-20.12.6.tgz",
"integrity": "sha512-3KurE8taB8GCvZBPngVbp0lk5CKi8M9f9k1rsADh0Evdz5SzJ+Q+Hx9uHoFGsLnLnd1xmkDQr2hVhlA0Mn0lKQ==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/electron/node_modules/extract-zip": { "node_modules/electron/node_modules/extract-zip": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
@ -16900,12 +16891,6 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/unicode-canonical-property-names-ecmascript": { "node_modules/unicode-canonical-property-names-ecmascript": {
"version": "1.0.4", "version": "1.0.4",
"dev": true, "dev": true,
@ -22293,25 +22278,16 @@
} }
}, },
"electron": { "electron": {
"version": "29.1.5", "version": "28.2.0",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-29.1.5.tgz", "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.2.0.tgz",
"integrity": "sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==", "integrity": "sha512-22SylXQQ9IHtwLw4D+Z4Si7OUpeDtpHfJVTjy3yv53iLg5zJKKPOCWT4ZwgYGHQZ0eldyBrYBHF/P9FPd2CcVQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^2.0.0", "@electron/get": "^2.0.0",
"@types/node": "^20.9.0", "@types/node": "^18.11.18",
"extract-zip": "^2.0.1" "extract-zip": "^2.0.1"
}, },
"dependencies": { "dependencies": {
"@types/node": {
"version": "20.12.6",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-20.12.6.tgz",
"integrity": "sha512-3KurE8taB8GCvZBPngVbp0lk5CKi8M9f9k1rsADh0Evdz5SzJ+Q+Hx9uHoFGsLnLnd1xmkDQr2hVhlA0Mn0lKQ==",
"dev": true,
"requires": {
"undici-types": "~5.26.4"
}
},
"extract-zip": { "extract-zip": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
@ -29687,12 +29663,6 @@
"version": "1.0.1", "version": "1.0.1",
"dev": true "dev": true
}, },
"undici-types": {
"version": "5.26.5",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"unicode-canonical-property-names-ecmascript": { "unicode-canonical-property-names-ecmascript": {
"version": "1.0.4", "version": "1.0.4",
"dev": true "dev": true

View File

@ -251,4 +251,4 @@
"pre-commit": "pretty-quick --staged && npm run lint" "pre-commit": "pretty-quick --staged && npm run lint"
} }
} }
} }

View File

@ -1,11 +1,7 @@
import { GenericServerOptions } from 'builder-util-runtime'; import { GenericServerOptions } from 'builder-util-runtime';
import electronLog from 'electron-log'; import electronLog from 'electron-log';
import { MacUpdater, NsisUpdater } from 'electron-updater'; import { MacUpdater, NsisUpdater } from 'electron-updater';
import * as fs from 'fs';
import { homedir as getHomedir } from 'os';
import * as path from 'path';
import { buildNumber, version } from '../../package.json';
import { isMac, isWindowsOS } from '../common/env'; import { isMac, isWindowsOS } from '../common/env';
import { logger } from '../common/logger'; import { logger } from '../common/logger';
import { isUrl } from '../common/utils'; import { isUrl } from '../common/utils';
@ -18,7 +14,6 @@ import { EChannelRegistry, RegistryStore } from './stores/registry-store';
import { windowHandler } from './window-handler'; import { windowHandler } from './window-handler';
const DEFAULT_AUTO_UPDATE_CHANNEL = 'apps/sda-update/default'; const DEFAULT_AUTO_UPDATE_CHANNEL = 'apps/sda-update/default';
const VERSION_REGEX = /version: (.*)/;
export enum AutoUpdateTrigger { export enum AutoUpdateTrigger {
MANUAL = 'MANUAL', MANUAL = 'MANUAL',
@ -36,8 +31,8 @@ export enum UpdateChannel {
} }
const DOWNLOAD_PROGRESS_BANNER_DELAY = 1000 * 10; // 10 sec const DOWNLOAD_PROGRESS_BANNER_DELAY = 1000 * 10; // 10 sec
const AUTO_UPDATE_REASON = 'autoUpdate'; const AUTO_UPDATE_REASON = 'autoUpdate';
const FORCE_UPDATE_TIMEOUT = 1000 * 10; // 10 sec
export class AutoUpdate { export class AutoUpdate {
public isUpdateAvailable: boolean = false; public isUpdateAvailable: boolean = false;
@ -49,7 +44,6 @@ export class AutoUpdate {
private channelConfigLocation: ChannelConfigLocation = private channelConfigLocation: ChannelConfigLocation =
ChannelConfigLocation.LOCALFILE; ChannelConfigLocation.LOCALFILE;
private downloadProgressDelayTimer: NodeJS.Timeout | null = null; private downloadProgressDelayTimer: NodeJS.Timeout | null = null;
private isForceUpdate: boolean = false;
constructor() { constructor() {
this.getGenericServerOptions().then((opts) => { this.getGenericServerOptions().then((opts) => {
@ -90,18 +84,6 @@ export class AutoUpdate {
await this.updateEventHandler(info, 'download-progress'); await this.updateEventHandler(info, 'download-progress');
}); });
this.autoUpdater.on('update-downloaded', async (info) => { this.autoUpdater.on('update-downloaded', async (info) => {
if (this.isForceUpdate) {
this.isForceUpdate = false;
logger.info(
'auto-update-handler: update downloaded and isForceUpdate',
);
// Handle update and restart for macOS
if (isMac) {
windowHandler.setIsAutoUpdating(true);
}
this.autoUpdater?.quitAndInstall();
return;
}
await this.updateEventHandler(info, 'update-downloaded'); await this.updateEventHandler(info, 'update-downloaded');
}); });
@ -116,62 +98,6 @@ export class AutoUpdate {
}); });
} }
/**
* Checks for updates and performs a forced installation if the latest version is already downloaded.
*/
public performForcedAutoUpdate = async () => {
const cacheDir = this.getCacheDir();
if (!cacheDir) {
logger.info(
'auto-update-handler: cache path does not exists, skipping forced auto-update.',
);
return;
}
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.',
);
return;
}
const files = fs.readdirSync(updaterFilePath, 'utf8');
if (!files.length) {
logger.info('auto-update-handler: no pending update files found');
return;
}
logger.info('auto-update-handler: pending update files', files);
const latestVersionFromServer = await this.fetchLatestVersion();
if (!latestVersionFromServer) {
logger.info(
'auto-update-handler: no version info from server skipping force auto update',
);
return;
}
const isOnLatestVersion =
latestVersionFromServer === `${version}-${buildNumber}`;
if (isOnLatestVersion) {
logger.info(
'auto-update-handler: already running the latest version skipping force update',
);
return;
}
const hasPendingInstaller = files.some(
(item) =>
item.includes(latestVersionFromServer) && !item.startsWith('temp'),
);
if (hasPendingInstaller) {
logger.info('auto-update-handler: latest version found force installing');
this.isForceUpdate = true;
await this.checkUpdates(AutoUpdateTrigger.AUTOMATED);
await this.downloadUpdate();
}
};
/** /**
* Installs the latest update quits and relaunches application * Installs the latest update quits and relaunches application
*/ */
@ -193,7 +119,6 @@ export class AutoUpdate {
if (isMac) { if (isMac) {
config.backupGlobalConfig(); config.backupGlobalConfig();
} }
logger.info('auto-update-handler: quitAndInstall');
this.autoUpdater.quitAndInstall(); this.autoUpdater.quitAndInstall();
} }
}); });
@ -257,63 +182,7 @@ export class AutoUpdate {
return updateUrl; return updateUrl;
}; };
private getCacheDir = () => {
const homedir = getHomedir();
if (isWindowsOS) {
return process.env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
} else if (isMac) {
return path.join(homedir, 'Library', 'Caches');
}
return;
};
private fetchLatestVersion = async (): Promise<string | void> => {
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',
url,
);
const controller = new AbortController();
const signal = controller.signal;
const timeoutId = setTimeout(
() => controller.abort(),
FORCE_UPDATE_TIMEOUT,
);
fetch(url, { signal })
.then((res) => res.blob())
.then((blob) => blob.text())
.then(async (response) => {
clearTimeout(timeoutId);
logger.info(
'auto-update-handler: latest version info from server',
response,
);
const match = VERSION_REGEX.exec(response);
if (match && match.length) {
logger.info('auto-update-handler: version found', match[1]);
resolve(match[1]);
} else {
resolve();
}
})
.catch(async (error) => {
logger.error(
'auto-update-handler: error fetching latest auto-update version from server',
url,
error,
);
resolve();
})
.finally(() => {
clearTimeout(timeoutId);
});
});
};
private updateEventHandler = async (info, eventType: string) => { private updateEventHandler = async (info, eventType: string) => {
logger.info('auto-update-handler: auto update events', info, eventType);
const mainWebContents = windowHandler.mainWebContents; const mainWebContents = windowHandler.mainWebContents;
if (mainWebContents && !mainWebContents.isDestroyed()) { if (mainWebContents && !mainWebContents.isDestroyed()) {
await this.setAutoUpdateChannel(); await this.setAutoUpdateChannel();

View File

@ -14,7 +14,6 @@ import { protocolHandler } from './protocol-handler';
import { ICustomBrowserWindow, windowHandler } from './window-handler'; import { ICustomBrowserWindow, windowHandler } from './window-handler';
import { autoLaunchInstance } from './auto-launch-controller'; import { autoLaunchInstance } from './auto-launch-controller';
import { autoUpdate } from './auto-update-handler';
import { presenceStatusStore } from './stores'; import { presenceStatusStore } from './stores';
// Set automatic period substitution to false because of a bug in draft js on the client app // Set automatic period substitution to false because of a bug in draft js on the client app
@ -108,7 +107,6 @@ const startApplication = async () => {
// Picks global config values and updates them in the user config // Picks global config values and updates them in the user config
await config.updateUserConfigOnStart(); await config.updateUserConfigOnStart();
setSessionProperties(); setSessionProperties();
await autoUpdate.performForcedAutoUpdate();
await windowHandler.createApplication(); await windowHandler.createApplication();
logger.info(`main: created application`); logger.info(`main: created application`);
}; };