diff --git a/build/installer.nsh b/build/installer.nsh index fd7a821e..73cecede 100644 --- a/build/installer.nsh +++ b/build/installer.nsh @@ -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" diff --git a/src/app/auto-update-handler.ts b/src/app/auto-update-handler.ts index 2e54affb..f749f936 100644 --- a/src/app/auto-update-handler.ts +++ b/src/app/auto-update-handler.ts @@ -102,6 +102,9 @@ export class AutoUpdate { } setImmediate(() => { if (this.autoUpdater) { + if (isMac) { + config.backupGlobalConfig(); + } this.autoUpdater.quitAndInstall(); } }); diff --git a/src/app/config-handler.ts b/src/app/config-handler.ts index 437853a2..2af23d5e 100644 --- a/src/app/config-handler.ts +++ b/src/app/config-handler.ts @@ -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 */ diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index 84635ee9..9fe2d210 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -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;