From ce72411ae34769de2548a64d7ae51f2022c1c53f Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Fri, 3 May 2024 08:32:11 +0530 Subject: [PATCH] Revert SDA-4489 (#2140) * Revert "SDA-4489 - Fix issue related to different env (#2137)" This reverts commit 3b39725f9d61b240ce770bda5ff497314871875b. * Revert "SDA-4489 - Invoke check for update & download before force install (#2132)" This reverts commit b3ea7c258a4237c88db0119b669014843d17ab0f. * Revert "SDA-4489 - Fix wrong import (#2129)" This reverts commit 6e82aca63024d299fb18fde0938fddb43c2a0305. * Revert "SDA-4489 (Force auto update) (#2128)" This reverts commit 68194f4a4c13371cd24a400f1554a5bac1ce6857. --- package-lock.json | 52 +++---------- package.json | 2 +- src/app/auto-update-handler.ts | 133 +-------------------------------- src/app/main.ts | 2 - 4 files changed, 13 insertions(+), 176 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9372534a..286bbbf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "symphony", - "version": "24.6.0", + "version": "24.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "symphony", - "version": "24.6.0", + "version": "24.4.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -40,7 +40,7 @@ "builder-util-runtime": "^9.0.3", "cross-env": "7.0.3", "del": "3.0.0", - "electron": "29.1.5", + "electron": "^28.2.0", "electron-builder": "^24.13.2", "electron-icon-maker": "0.0.5", "electron-osx-sign": "^0.6.0", @@ -6337,14 +6337,14 @@ } }, "node_modules/electron": { - "version": "29.1.5", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-29.1.5.tgz", - "integrity": "sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==", + "version": "28.2.0", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.2.0.tgz", + "integrity": "sha512-22SylXQQ9IHtwLw4D+Z4Si7OUpeDtpHfJVTjy3yv53iLg5zJKKPOCWT4ZwgYGHQZ0eldyBrYBHF/P9FPd2CcVQ==", "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", - "@types/node": "^20.9.0", + "@types/node": "^18.11.18", "extract-zip": "^2.0.1" }, "bin": { @@ -6788,15 +6788,6 @@ "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": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", @@ -16900,12 +16891,6 @@ "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": { "version": "1.0.4", "dev": true, @@ -22293,25 +22278,16 @@ } }, "electron": { - "version": "29.1.5", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-29.1.5.tgz", - "integrity": "sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==", + "version": "28.2.0", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.2.0.tgz", + "integrity": "sha512-22SylXQQ9IHtwLw4D+Z4Si7OUpeDtpHfJVTjy3yv53iLg5zJKKPOCWT4ZwgYGHQZ0eldyBrYBHF/P9FPd2CcVQ==", "dev": true, "requires": { "@electron/get": "^2.0.0", - "@types/node": "^20.9.0", + "@types/node": "^18.11.18", "extract-zip": "^2.0.1" }, "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": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", @@ -29687,12 +29663,6 @@ "version": "1.0.1", "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": { "version": "1.0.4", "dev": true diff --git a/package.json b/package.json index 3459969b..e6e0eb11 100644 --- a/package.json +++ b/package.json @@ -251,4 +251,4 @@ "pre-commit": "pretty-quick --staged && npm run lint" } } -} +} \ No newline at end of file diff --git a/src/app/auto-update-handler.ts b/src/app/auto-update-handler.ts index 0c078510..45674950 100644 --- a/src/app/auto-update-handler.ts +++ b/src/app/auto-update-handler.ts @@ -1,11 +1,7 @@ import { GenericServerOptions } from 'builder-util-runtime'; import electronLog from 'electron-log'; 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 { logger } from '../common/logger'; import { isUrl } from '../common/utils'; @@ -18,7 +14,6 @@ import { EChannelRegistry, RegistryStore } from './stores/registry-store'; import { windowHandler } from './window-handler'; const DEFAULT_AUTO_UPDATE_CHANNEL = 'apps/sda-update/default'; -const VERSION_REGEX = /version: (.*)/; export enum AutoUpdateTrigger { MANUAL = 'MANUAL', @@ -36,8 +31,8 @@ export enum UpdateChannel { } const DOWNLOAD_PROGRESS_BANNER_DELAY = 1000 * 10; // 10 sec + const AUTO_UPDATE_REASON = 'autoUpdate'; -const FORCE_UPDATE_TIMEOUT = 1000 * 10; // 10 sec export class AutoUpdate { public isUpdateAvailable: boolean = false; @@ -49,7 +44,6 @@ export class AutoUpdate { private channelConfigLocation: ChannelConfigLocation = ChannelConfigLocation.LOCALFILE; private downloadProgressDelayTimer: NodeJS.Timeout | null = null; - private isForceUpdate: boolean = false; constructor() { this.getGenericServerOptions().then((opts) => { @@ -90,18 +84,6 @@ export class AutoUpdate { await this.updateEventHandler(info, 'download-progress'); }); 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'); }); @@ -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 */ @@ -193,7 +119,6 @@ export class AutoUpdate { if (isMac) { config.backupGlobalConfig(); } - logger.info('auto-update-handler: quitAndInstall'); this.autoUpdater.quitAndInstall(); } }); @@ -257,63 +182,7 @@ export class AutoUpdate { 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 => { - 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) => { - logger.info('auto-update-handler: auto update events', info, eventType); const mainWebContents = windowHandler.mainWebContents; if (mainWebContents && !mainWebContents.isDestroyed()) { await this.setAutoUpdateChannel(); diff --git a/src/app/main.ts b/src/app/main.ts index 80b554f5..50b5b51b 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -14,7 +14,6 @@ import { protocolHandler } from './protocol-handler'; import { ICustomBrowserWindow, windowHandler } from './window-handler'; import { autoLaunchInstance } from './auto-launch-controller'; -import { autoUpdate } from './auto-update-handler'; import { presenceStatusStore } from './stores'; // 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 await config.updateUserConfigOnStart(); setSessionProperties(); - await autoUpdate.performForcedAutoUpdate(); await windowHandler.createApplication(); logger.info(`main: created application`); };