Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files): Reverse logic to prevent copy to itself #41709

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(files): Correct condition for checking copy/move into same directory
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Nov 27, 2023
commit 2357f839fefa4cb0629e7fe29d3f2c1ab9d92fd3
8 changes: 7 additions & 1 deletion apps/files/src/actions/moveOrCopyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
}

Expand Down