TagSpaces is an offline, open source, document manager with tagging support
fix: issue trying to rename a folder with the same name
Ilian Sapundshiev5894f044555c
diff --git a/src/renderer/components/dialogs/RenameEntryDialog.tsx b/src/renderer/components/dialogs/RenameEntryDialog.tsxindex 68ac066c4..5415c9710 100644--- a/src/renderer/components/dialogs/RenameEntryDialog.tsx+++ b/src/renderer/components/dialogs/RenameEntryDialog.tsx@@ -144,7 +144,13 @@ function RenameEntryDialog(props: Props) {: '') + name.current;return renameFile(originPath, newFilePath, currentLocation.uuid);} else {- return renameDirectory(originPath, name.current, currentLocation.uuid);+ return renameDirectory(+ originPath,+ name.current,+ currentLocation.uuid,+ ).catch(() => {+ // notification already shown by renameDirectory; swallow to avoid uncaught rejection+ });}}};diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsxindex 17cd27270..81e6dd699 100644--- a/src/renderer/hooks/IOActionsContextProvider.tsx+++ b/src/renderer/hooks/IOActionsContextProvider.tsx@@ -1580,11 +1580,17 @@ export const IOActionsContextProvider = ({}).catch((error) => {console.log('Error while renaming directory: ' + error);+ const reason =+ typeof error === 'string' ? error : error?.message || String(error);+ const targetExists = /exists\. Renaming of/i.test(reason);+ const dirName = extractDirectoryName(+ directoryPath,+ currentLocation?.getDirSeparator(),+ );showNotification(- `Error renaming directory '${extractDirectoryName(- directoryPath,- currentLocation?.getDirSeparator(),- )}'`,+ targetExists+ ? `Cannot rename '${dirName}': a directory with the new name already exists.`+ : `Error renaming directory '${dirName}': ${reason}`,'error',true,);