add trailing slash to restore_path for trashed directories#4794
add trailing slash to restore_path for trashed directories#4794JF-Cozy wants to merge 2 commits into
Conversation
|
|
||
| var newdoc *FileDoc | ||
| restorePath := path.Dir(oldpath) | ||
| restorePath := path.Dir(oldpath) + "/" |
There was a problem hiding this comment.
what will be for the files with "/" as an oldpath? I think we should keep root unchanged
Add a trailing `/` to `restore_path` when trashing files and directories. This prevents false positives when querying the trash of shared drives with similar names — without it, a `$gte: "/Shared Drives/Test"` query also captures files from "/Shared Drives/Test 2/...". No impact on `RestoreDir` / `RestoreFile` — `DirByPath` uses `path.Clean` which strips trailing slashes, and `path.Join` normalizes paths.
a19cd7b to
dd76641
Compare
|
@JF-Cozy is it sitll relevant for displaying trash in admin panel? |
|
Not prioritized today, and a more robust approach using referenced_by would be better, so we can close it for now. Here's a full summary of the problem and solutions: ContextWhen two shared drives have names sharing a common prefix (e.g. "Shared" and "Shared Drive"), the trash view of one drive leaks files from the other. The cozy-admin trash query scopes the listing with a lexicographic range on Because Approach A — trailing slash on
|
Add a trailing
/torestore_path(path of the parent folder) when trashing files and directories. This prevents false positives when querying the trash of shared drives with similar names — without it, a$gte: "/Shared Drives/Test"query also captures files from"/Shared Drives/Test 2/...".No impact on
RestoreDir/RestoreFile—DirByPathusespath.Cleanwhich strips trailing slashes, andpath.Joinnormalizes paths.App must change fetch from
to