Repository navigation
fix: restore parent folders before their children from the trash - #4076
Merged
Merged
Conversation
JammingBen
force-pushed
the
fix/restore-parent-folder-in-batch
branch
from
October 30, 2026 08:50
0f4f9b2 to
d22a942
Compare
JammingBen
marked this pull request as ready for review
October 30, 2026 09:58
kulmann
reviewed
Oct 30, 2026
| } | ||
|
|
||
| // restore level by level so parent folders in the batch exist before their children | ||
| const depths = [...new Set(resources.map(({ path }) => getDepth(path)))].sort((a, b) => a - b) |
Member
There was a problem hiding this comment.
TIL: there is Map.groupBy 🙈 with that you can do:
const resourcesByDepth = Map.groupBy(resources, ({ path }) => getDepth(path))
const sortedDepths = [...resourcesByDepth.keys()].sort((a, b) => a - b)
for (const depth of sortedDepths) {
await Promise.allSettled(
resourcesByDepth.get(depth).map((r) => queue.add(() => restoreResource(r)))
)
}which saves you filtering "again and again" (well... to be fair, that's a bit exaggerated) per depth value.
Member
Author
There was a problem hiding this comment.
My agent warned me though that not every Browser we officially support also supports this, since it's a somewhat new ES2024 feature.
kulmann
approved these changes
Oct 30, 2026
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.
Description
Restoring a trashed folder together with items from inside it (e.g. "select all" in the trash bin) could create an empty folder for the child first. The restore of the actual folder then replaced it, sending the child back to the trash.
file (1).txt) if that item is restored, and stays in the trash if it is skipped.How to test
Parent folders:
keep.mdanda.md. Deletea.md, then the folder.Duplicates in one batch:
file.txttwice, then createfile.txtonce more.file.txtand Restore, choose "Skip": nothing is restored.file (1).txt.file.txtso none exists, restore both:file.txtandfile (1).txt, no dialog.Limitations
This is a can of worms, more known issues are filed in #4077.