Skip to content

fix: preserve concurrently deleted large folders in trash - #63009

Open
mvanhorn wants to merge 1 commit into
nextcloud:masterfrom
mvanhorn:fix/44414-batch-trash-folder-moves
Open

mvanhorn wants to merge 1 commit into
nextcloud:masterfrom
mvanhorn:fix/44414-batch-trash-folder-moves

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Deleting several large folders at the same time can remove every source folder while leaving fewer top-level entries visible in the user's trash bin. The report reproduces this with three folders containing 10,000 files each, and rules out quota-driven trash expiration.

Each Trashbin::move2trash call transfers a large cache subtree and immediately propagates changes through shared source and trash ancestors, while the existing destination lock only coordinates collisions for a single generated trash filename. That leaves distinct concurrent folder moves mutating the same file-cache ancestry without the batched propagation that the trash expiration path already uses.

This wraps the move-to-trash payload and cache mutation in beginBatch() / commitBatch() on the trash storage propagator, so the ancestor updates from one folder move are collected and committed together rather than piecemeal. The batch is balanced with try/finally so it is committed on failed moves and on the cleanup paths as well. Per-destination locking, metadata insertion, version retention, expiration scheduling, and return behavior are unchanged.

The semantic change is six lines; the rest of the diff in Trashbin.php is the reindentation that wrapping introduces, so git diff -w is the easier read.

Honest status

I could not run the test suite locally, so the two new tests in StorageTest.php have not been executed anywhere yet. CI will be their first run, and I will fix whatever it turns up.

The underlying report has no deterministic reproduction, so treat the diagnosis as a hypothesis rather than something I have observed under a debugger. If maintainers who know this code think the batching is the wrong direction, I am happy to close this.

Checklist

  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Code is properly formatted (not verified locally, no linter available in my environment)
  • Screenshots before/after for front-end changes (not applicable, no front-end change)
  • Documentation (manuals or wiki) has been updated or is not required
  • Backports requested where applicable (ex: critical bugfixes)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component)
  • Milestone added for target branch/version (ex: 32.x for stable32)

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mvanhorn
mvanhorn requested a review from a team as a code owner August 7, 2026 09:13
@mvanhorn
mvanhorn requested review from Altahrim, come-nc, leftybournes and salmart-dev and removed request for a team August 7, 2026 09:13
@come-nc
come-nc removed their request for review August 10, 2026 08:15
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Batch the file-cache propagation around the move-to-trash payload and
cache mutation, using the propagator batching that the trash expiration
path already relies on, so ancestor updates from one folder move are
collected and committed together instead of being propagated piecemeal
through shared source and trash ancestry.

The batch is balanced with try/finally so it is committed on failed
moves and on the cleanup paths as well.

Fixes nextcloud#44414

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn
mvanhorn force-pushed the fix/44414-batch-trash-folder-moves branch from 3fd4d9a to f360e29 Compare August 23, 2026 08:17
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 12, 2026

This branch has not been deployed

No deployments
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.

[Bug]: Deleting multiple big folders results in possibly missing folders from trash bin

2 participants