]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): Correct condition for checking copy/move into same directory
authorFerdinand Thiessen <opensource@fthiessen.de>
Thu, 23 Nov 2023 20:34:36 +0000 (21:34 +0100)
committerFerdinand Thiessen <opensource@fthiessen.de>
Mon, 27 Nov 2023 18:12:19 +0000 (19:12 +0100)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
apps/files/src/actions/moveOrCopyAction.ts

index 17e9370e8d9c81abd618290215a7024b9f12e9c9..22afb79c4d6f4d72b4b1b8dd42a6efb155aeb2d4 100644 (file)
@@ -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'))
        }