✨(frontend) preserve empty folders on drag & drop upload#655
Merged
PanchoutNathan merged 3 commits intomainfrom Apr 16, 2026
Merged
✨(frontend) preserve empty folders on drag & drop upload#655PanchoutNathan merged 3 commits intomainfrom
PanchoutNathan merged 3 commits intomainfrom
Conversation
React-dropzone's default traversal silently drops empty directories because webkitGetAsEntry()'s readEntries() yields no entry for them. Add a custom getFilesFromEvent that walks the drop tree ourselves and emits a zero-byte marker file for every empty folder. The marker carries an isEmptyFolder flag and a path so useUpload can materialize the folder chain via getFolderByPath, then skip the marker before any size validation or backend upload. When a drop contains only empty-folder markers, the file upload toast is suppressed and a dedicated success toast is shown once the folders have been created. Input change events (folder/file buttons) are delegated to file-selector, matching the Google Drive / Proton Drive limitation around <input webkitdirectory>.
Cover the custom drop traversal helpers: empty-folder marker creation, batched readEntries() loop, recursive entry walking for files, nested non-empty folders, and empty directories, plus the customGetFilesFromEvent entry point for drop events and its delegation to file-selector for non-drag inputs.
Use String.localeCompare in three test sort() calls to satisfy the reliability rule S2871, and drop the redundant Event branch of the Event | unknown parameter type in customGetFilesFromEvent (S6571).
87cebad to
51552ac
Compare
|
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
getFilesFromEventfor react-dropzone that walks thedrop tree ourselves and emits a zero-byte marker file for every
empty folder, so empty directories dropped into the explorer are
now created instead of being silently dropped.
useUploadto materialize the folder chain from markers viagetFolderByPath, then filter them out before any size validationor backend upload. When a drop contains only markers, the file
upload toast is suppressed and a dedicated success toast is shown
once the folders have been created.
readEntries()loop, recursive entry walking, and thecustomGetFilesFromEvententry point.Input change events (folder/file buttons) remain delegated to
file-selector: the browser does not expose empty folders through<input webkitdirectory>, matching the Google Drive / Proton Drivelimitation.
Test plan
created with the success toast.
confirm both the files and the empty folders land correctly.
shows progress.
confirm the existing behavior is unchanged.
dropTraversal.test.ts.