Browse Source

fix(files): Correct condition for checking copy/move into same directory

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Ferdinand Thiessen 6 months ago
parent
commit
2357f839fe
1 changed files with 7 additions and 1 deletions
  1. 7 1
      apps/files/src/actions/moveOrCopyAction.ts

+ 7 - 1
apps/files/src/actions/moveOrCopyAction.ts

@@ -80,7 +80,13 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
 		throw new Error(t('files', 'This file/folder is already in that directory'))
 	}
 
-	if (node.path.startsWith(destination.path)) {
+	/**
+	 * Example:
+	 * node: /foo/bar/file.txt -> path = /foo/bar
+	 * destination: /foo
+	 * Allow move of /foo does not start with /foo/bar so allow
+	 */
+	if (destination.path.startsWith(node.path)) {
 		throw new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself'))
 	}