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

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/41709/head
Ferdinand Thiessen 6 months ago
parent c54c6a8a13
commit 2357f839fe
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400

@ -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'))
}

Loading…
Cancel
Save