Skip to content

add trailing slash to restore_path for trashed directories#4794

Open
JF-Cozy wants to merge 2 commits into
masterfrom
feat/restore_path
Open

add trailing slash to restore_path for trashed directories#4794
JF-Cozy wants to merge 2 commits into
masterfrom
feat/restore_path

Conversation

@JF-Cozy

@JF-Cozy JF-Cozy commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Add a trailing / to restore_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 / RestoreFileDirByPath uses path.Clean which strips trailing slashes, and path.Join normalizes paths.

App must change fetch from

    Q(FILES_DOCTYPE)
      .where({
        dir_id: TRASH_DIR_ID,
        type,
        name: { $gt: null },
        restore_path: { $gte: path, $lt: path + '\ufff0' }
      })

to

    Q(FILES_DOCTYPE)
      .where({
        dir_id: TRASH_DIR_ID,
        type,
        name: { $gt: null },
        restore_path: { $gte: path + '/', $lt: path + '\ufff0' }

@JF-Cozy JF-Cozy requested a review from a team as a code owner June 11, 2026 11:30
Comment thread model/vfs/file.go

var newdoc *FileDoc
restorePath := path.Dir(oldpath)
restorePath := path.Dir(oldpath) + "/"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will be for the files with "/" as an oldpath? I think we should keep root unchanged

JF-Cozy added 2 commits June 12, 2026 10:21
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.
@shepilov shepilov force-pushed the feat/restore_path branch from a19cd7b to dd76641 Compare June 12, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants