diff --git a/packages/desktop/electron/electronApi.js b/packages/desktop/electron/electronApi.js index fe772a10881..dda396d122b 100644 --- a/packages/desktop/electron/electronApi.js +++ b/packages/desktop/electron/electronApi.js @@ -13,6 +13,17 @@ const ElectronApi = { updateAppSettings(settings) { return ipcRenderer.invoke('update-app-settings', settings) }, + async renameProfileFolder(oldPath, newPath) { + return ipcRenderer.invoke('get-path', 'userData').then((userDataPath) => { + if (oldPath.startsWith(userDataPath)) { + try { + fs.renameSync(oldPath, newPath) + } catch (err) { + console.error(err) + } + } + }) + }, async removeProfileFolder(profilePath) { return ipcRenderer.invoke('get-path', 'userData').then((userDataPath) => { // Check that the removing profile path matches the user data path diff --git a/packages/shared/lib/core/app/interfaces/platform.interface.ts b/packages/shared/lib/core/app/interfaces/platform.interface.ts index adb1d31d6c4..7136906f851 100644 --- a/packages/shared/lib/core/app/interfaces/platform.interface.ts +++ b/packages/shared/lib/core/app/interfaces/platform.interface.ts @@ -15,6 +15,7 @@ export interface IPlatform { updateAppSettings(settings: Partial): Promise updateActiveProfile(id: string): void removeProfileFolder(profilePath: string): Promise + renameProfileFolder(oldPath: string, newPath: string): Promise listProfileFolders(profileStoragePath: string): Promise updateMenu(attribute: string, value: unknown): void popupMenu(): void diff --git a/packages/shared/lib/tests/__mocks__/platform.mock.ts b/packages/shared/lib/tests/__mocks__/platform.mock.ts index fa5fb016e71..12dc2670543 100644 --- a/packages/shared/lib/tests/__mocks__/platform.mock.ts +++ b/packages/shared/lib/tests/__mocks__/platform.mock.ts @@ -41,6 +41,9 @@ const Platform: IPlatform = { removeProfileFolder(profilePath: string): Promise { return Promise.resolve(undefined) }, + renameProfileFolder(oldPath: string, newPath: string): Promise { + return Promise.resolve(undefined) + }, saveRecoveryKit(kitData: ArrayBuffer): Promise { return Promise.resolve(undefined) },