mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-22 08:57:00 -06:00
SDA-3800 (Backup and overwrite global config to persist data) (#1469)
* SDA-3800 - Copy and replace global config * SDA-3800 - Copy and replace global config - macOS
This commit is contained in:
parent
50b7276ea8
commit
c36c71d6e0
@ -19,11 +19,32 @@ Function uninstallSymphony
|
||||
done:
|
||||
FunctionEnd
|
||||
|
||||
!macro copySystemGlobalConfig
|
||||
IfFileExists $PROGRAMFILES64\Symphony\Symphony\config\Symphony.config 0 +2
|
||||
CopyFiles /SILENT $PROGRAMFILES64\Symphony\Symphony\config\Symphony.config $WINDIR\Temp\temp-sys-Symphony.config
|
||||
!macroend
|
||||
|
||||
!macro copyLocalGlobalConfig
|
||||
IfFileExists $LOCALAPPDATA\Symphony\Symphony\config\Symphony.config 0 +2
|
||||
CopyFiles /SILENT $LOCALAPPDATA\Symphony\Symphony\config\Symphony.config $WINDIR\Temp\temp-local-Symphony.config
|
||||
!macroend
|
||||
|
||||
!macro replaceSystemGlobalConfig
|
||||
IfFileExists $WINDIR\Temp\temp-sys-Symphony.config 0 +2
|
||||
CopyFiles /SILENT $WINDIR\Temp\temp-sys-Symphony.config $PROGRAMFILES64\Symphony\Symphony\config\Symphony.config
|
||||
!macroend
|
||||
|
||||
!macro replaceLocalGlobalConfig
|
||||
IfFileExists $WINDIR\Temp\temp-local-Symphony.config 0 +2
|
||||
CopyFiles /SILENT $WINDIR\Temp\temp-local-Symphony.config $PROGRAMFILES64\Symphony\Symphony\config\Symphony.config
|
||||
!macroend
|
||||
|
||||
!macro bothM
|
||||
MessageBox MB_OK "Auto update not supported as there is two version installed"
|
||||
!macroend
|
||||
|
||||
!macro perUserM
|
||||
!insertmacro copyLocalGlobalConfig
|
||||
Call uninstallSymphony
|
||||
Sleep 10000
|
||||
SetRegView 64
|
||||
@ -37,6 +58,7 @@ FunctionEnd
|
||||
!insertmacro UAC_RunElevated
|
||||
Quit
|
||||
${endif}
|
||||
!insertmacro copySystemGlobalConfig
|
||||
Call uninstallSymphony
|
||||
Sleep 10000
|
||||
SetRegView 64
|
||||
@ -70,6 +92,16 @@ FunctionEnd
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro customInstall
|
||||
${If} $PerUser == "exists"
|
||||
!insertmacro replaceLocalGlobalConfig
|
||||
${ElseIf} $AllUser == "exists"
|
||||
!insertmacro replaceSystemGlobalConfig
|
||||
${Else}
|
||||
!insertmacro abortM
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro customUnInit
|
||||
!insertmacro validateInstallation
|
||||
${If} $AllUser == "exists"
|
||||
|
@ -102,6 +102,9 @@ export class AutoUpdate {
|
||||
}
|
||||
setImmediate(() => {
|
||||
if (this.autoUpdater) {
|
||||
if (isMac) {
|
||||
config.backupGlobalConfig();
|
||||
}
|
||||
this.autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
|
@ -144,6 +144,7 @@ class Config {
|
||||
private bootCount: number | undefined;
|
||||
private readonly configFileName: string;
|
||||
private readonly installVariantFilename: string;
|
||||
private readonly tempGlobalConfigFilePath: string;
|
||||
private readonly installVariantPath: string;
|
||||
private readonly userConfigPath: string;
|
||||
private readonly appPath: string;
|
||||
@ -152,6 +153,10 @@ class Config {
|
||||
|
||||
constructor() {
|
||||
this.configFileName = 'Symphony.config';
|
||||
this.tempGlobalConfigFilePath = path.join(
|
||||
app.getPath('userData'),
|
||||
'temp-local.Symphony.config',
|
||||
);
|
||||
this.installVariantFilename = 'InstallVariant.info';
|
||||
this.userConfigPath = path.join(
|
||||
app.getPath('userData'),
|
||||
@ -594,6 +599,23 @@ class Config {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backup of the global config file
|
||||
*/
|
||||
public backupGlobalConfig() {
|
||||
fs.copyFileSync(this.globalConfigPath, this.tempGlobalConfigFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the global config file with the backed up config file
|
||||
*/
|
||||
public copyGlobalConfig() {
|
||||
if (fs.existsSync(this.tempGlobalConfigFilePath)) {
|
||||
fs.copyFileSync(this.tempGlobalConfigFilePath, this.globalConfigPath);
|
||||
fs.unlinkSync(this.tempGlobalConfigFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* filters out the cloud config
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@ import {
|
||||
IApiArgs,
|
||||
INotificationData,
|
||||
} from '../common/api-interface';
|
||||
import { isMac } from '../common/env';
|
||||
import { i18n, LocaleType } from '../common/i18n';
|
||||
import { logger } from '../common/logger';
|
||||
import { activityDetection } from './activity-detection';
|
||||
@ -343,6 +344,9 @@ ipcMain.on(
|
||||
break;
|
||||
case apiCmds.setPodUrl:
|
||||
await config.updateUserConfig({ url: arg.newPodUrl });
|
||||
if (isMac) {
|
||||
config.copyGlobalConfig();
|
||||
}
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user