Skip to content

fix(search): keep trashed and live folders at the same path apart - #3602

Open
aduffeck wants to merge 1 commit into
opencloud-eu:mainfrom
aduffeck:fix/search-trashed-path-collision
Open

aduffeck wants to merge 1 commit into
opencloud-eu:mainfrom
aduffeck:fix/search-trashed-path-collision

Conversation

@aduffeck

@aduffeck aduffeck commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

A trashed folder keeps its path in the index, so a live folder can take the same path. Move/delete/restore/purge looked up descendants by path only. As a result, purging the trashed ./a removed the live ./a tree, and moving the live ./a took the trashed tree with it. Both engines now also match the root's trash state.

A trashed folder keeps its path in the index, so a new folder can take
the same one. The descendant lookup behind move, delete, restore and
purge matched on space and path only: purging the trashed folder took
the live folder and its descendants out of the index, and moving the
live folder carried the trashed tree along.

Both engines now also match the root's trash state; purge with
onlyDeleted keeps matching the trashed ones only.
@codacy-production

codacy-production Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 63.16% diff coverage

Metric Results
Coverage variation Report missing for 74462d31
Diff coverage ✅ 63.16% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (74462d3) Report Missing Report Missing Report Missing
Head commit (ad4c8ad) 89040 21575 24.23%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3602) 19 12 63.16%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dschmidt dschmidt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of adding the deleted / onlyDeleted bools to forEachResourceByPath and forSelfAndDescendants, should the caller pass the query into forEachResourceByPath? It would then only do the paging, and each caller adds the Deleted filter it needs.

Roughly, with three small new helpers:

  • treeQuery(root): the RootID + Path conjunction that forEachResourceByPath builds inline today
  • deletedQuery(deleted): the Deleted bool field query
  • b.pushing(fn): the current apply closure from forSelfAndDescendants, pulled out so Purge can use it too
// forSelfAndDescendants(id, fn): back to the signature from main
q := treeQuery(root)
q.AddQuery(deletedQuery(root.Deleted))
forEachResourceByPath(q, b.index, fn)

// Purge(id, true): doesn't go through forSelfAndDescendants
q := treeQuery(root)
q.AddQuery(deletedQuery(true)) // also leaves out the live root, since the Path term matches the folder itself
forEachResourceByPath(q, b.index, b.pushing(purge))

In forSelfAndDescendants the query has to be built before fn(root) runs, just like rootPath today.

Personally I really dislike boolean parameters as I think it's really hard to reason about what they are doing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants