From 2e4051b0220848f33818bb34b57cd0a2c823d14c Mon Sep 17 00:00:00 2001 From: Pragadesh-45 <54320162+Pragadesh-45@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:02:15 +0530 Subject: [PATCH] Bugfix/rename with same name for `Environments` (#3199) * added safe to rename for rename-environment to enable case insensitive file change * chore: removed else block --------- Co-authored-by: Anoop M D --- .../EnvironmentSettings/RenameEnvironment/index.js | 3 +++ packages/bruno-electron/src/ipc/collection.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bruno-app/src/components/Environments/EnvironmentSettings/RenameEnvironment/index.js b/packages/bruno-app/src/components/Environments/EnvironmentSettings/RenameEnvironment/index.js index ac2d2623a..3ebcadca1 100644 --- a/packages/bruno-app/src/components/Environments/EnvironmentSettings/RenameEnvironment/index.js +++ b/packages/bruno-app/src/components/Environments/EnvironmentSettings/RenameEnvironment/index.js @@ -22,6 +22,9 @@ const RenameEnvironment = ({ onClose, environment, collection }) => { .required('name is required') }), onSubmit: (values) => { + if (values.name === environment.name) { + return; + } dispatch(renameEnvironment(values.name, environment.uid, collection.uid)) .then(() => { toast.success('Environment renamed successfully'); diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index 4b53e4b81..950902ece 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -298,7 +298,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection } const newEnvFilePath = path.join(envDirPath, `${newName}.bru`); - if (fs.existsSync(newEnvFilePath)) { + if (!safeToRename(envFilePath, newEnvFilePath)) { throw new Error(`environment: ${newEnvFilePath} already exists`); }