From 6ea18017872463cc0e1712e7e153e1938d62ba28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20=C3=81lvarez=20de=20la=20Cruz?= Date: Thu, 7 Mar 2024 17:25:51 +0100 Subject: [PATCH] revert: bring back renameProfileFolder (#8170) --- packages/desktop/electron/electronApi.js | 11 +++++++++++ .../lib/core/app/interfaces/platform.interface.ts | 1 + packages/shared/lib/tests/__mocks__/platform.mock.ts | 3 +++ 3 files changed, 15 insertions(+) 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) },