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

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2023-11-23 21:34:36 +01:00
parent 77970de9f3
commit f695df8506
No known key found for this signature in database
GPG key ID: 45FAE7268762B400

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