fix(files_trashbin): normalize paths before restoring and deleting - #62981
Draft
joshtrichards wants to merge 4 commits into
Draft
fix(files_trashbin): normalize paths before restoring and deleting#62981joshtrichards wants to merge 4 commits into
joshtrichards wants to merge 4 commits into
Conversation
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
In particular the "legacy" part is a bit confusing (and can be misconstrued) until realizing it's a essentially wrapper... Signed-off-by: Josh <josh.t.richards@gmail.com>
…etion Signed-off-by: Josh <josh.t.richards@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix leading-slash handling when
LegacyTrashBackendpasses trash item paths toTrashbin::restore()andTrashbin::delete()APIs.ITrashItem::getTrashPath()currently returns paths with a leading slash, for example:The
TrashbinAPIs expect paths relative tofiles_trashbin/files/. Passing the slash-prefixed value can produce paths such as:Filesystem path normalization currently masks the extra slash, but for permanent deletion the leading slash also causes the
files_trashdatabase cleanup query to use/file.txtinstead of the stored IDfile.txt. As a result, the physical trash item is deleted but its metadata row remains.This change normalizes the path at the
LegacyTrashBackendboundary before callingTrashbin::restore()andTrashbin::delete(), keeping those callers consistent with the APIs' relative-path contract.Changes:
Trashbin::restore()andTrashbin::delete()docblocks.Thedelete()documentation was already relatively clear;restore()required the more substantial clarification.LegacyTrashBackend::restoreItem()LegacyTrashBackend::removeItem()files_trashrow;The existing
ITrashItempath representation is unchanged to avoid affecting other consumers that rely on its leading slash.Follow-up ideas
files_trashrows are not repaired by this change, but they are already orphaned today. This fix prevents new incorrect rows from being left behind. Historical metadata cleanup can be addressed separately in a follow-up repair PR.files_versionsfor anything possibly similar (not necessary applicable - just came to mind)TODO
ITrashBackendimplementation for similar issues (though any changes will obviously be handled in a separate PR)Checklist
3. to review, feature component)stable32)AI (if applicable)