mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-21 08:34:40 -06:00
Revert SDA-4489 (#2140)
* Revert "SDA-4489 - Fix issue related to different env (#2137)" This reverts commit3b39725f9d
. * Revert "SDA-4489 - Invoke check for update & download before force install (#2132)" This reverts commitb3ea7c258a
. * Revert "SDA-4489 - Fix wrong import (#2129)" This reverts commit6e82aca630
. * Revert "SDA-4489 (Force auto update) (#2128)" This reverts commit68194f4a4c
.
This commit is contained in:
parent
020cd05eab
commit
ce72411ae3
52
package-lock.json
generated
52
package-lock.json
generated
@ -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
|
||||
|
@ -251,4 +251,4 @@
|
||||
"pre-commit": "pretty-quick --staged && npm run lint"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<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) => {
|
||||
logger.info('auto-update-handler: auto update events', info, eventType);
|
||||
const mainWebContents = windowHandler.mainWebContents;
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
await this.setAutoUpdateChannel();
|
||||
|
@ -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`);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user