fix(unzip): preserve subfolder structure when extracting archives#443
Open
dschmidt wants to merge 1 commit into
Open
fix(unzip): preserve subfolder structure when extracting archives#443dschmidt wants to merge 1 commit into
dschmidt wants to merge 1 commit into
Conversation
5e9d798 to
31bc410
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug where unzipping archives lost their nested folder structure. The root cause was that the unzip handler set webkitRelativePath on file.meta, but uppyService's onBeforeFileAdded overrides meta.relativePath from file.data.relativePath/file.data.webkitRelativePath only. The fix attaches relativePath to the data Blob (matching uppy's convention used by drag-and-drop folder upload).
Changes:
- Attach
relativePathdirectly to the extracted file's data Blob (typed via localFileWithPath) and drop the now-ineffectivewebkitRelativePathonmeta. - Unskip and extend the e2e test to verify nested folder preservation, with a temporary workaround for an unrelated "Folder already exists" dialog (web#2513).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/web-app-unzip/src/composables/useUnzipAction.ts | Sets relativePath on the data blob instead of webkitRelativePath on meta so uppyService preserves subfolder structure. |
| packages/web-app-unzip/tests/e2e/extractZip.spec.ts | Enables the previously skipped e2e test and adds assertions for nested directory preservation; dismisses an unrelated false-positive merge dialog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e1224d7 to
86cb833
Compare
extracted files lost their subfolder paths and ended up flat inside the extraction folder. the handler set webkitRelativePath on file.meta, but uppyService.onBeforeFileAdded recomputes meta.relativePath from file.data.relativePath || file.data.webkitRelativePath, neither of which the unzip handler was setting on the blob. attach relativePath directly to the data blob (matching uppy's convention, the same one used by DropTarget.getDroppedFiles for drag-and-drop folder uploads). uppyService now picks it up, populates meta.relativePath, and HandleUpload creates the nested directory tree as expected. regression: introduced by opencloud-eu/web@e1828e7f70 ("refactor: switch back to upstream uppy", 2024-12-20), which dropped the meta.relativePath || meta.webkitRelativePath fallback in HandleUpload. unskips the previously skipped e2e test (its original blocker, opencloud-eu/web#2506, has landed on main) and extends it to assert the preserved subfolder structure as a regression for #293. data.zip wraps its content in a "data/" folder matching the archive name, which trips a false-positive "Folder already exists" dialog in HandleUpload (the conflict detector checks the user's current folder instead of the actual upload target. see opencloud-eu/web#2513). the e2e dismisses the dialog with "Merge" so this PR is independently mergeable. once web#2513 is bundled in the published OpenCloud image, the wait will time out and fail the test as a reminder to remove the workaround.
86cb833 to
c322475
Compare
7 tasks
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
Extracted files lost their subfolder paths and ended up flat inside the extraction folder. For example, extracting
maps-1.0.2.zip(which containsjs/maps-uKkx1qsf.js) putmaps-uKkx1qsf.jsdirectly into the extraction folder instead of insidejs/.Root cause
The handler set
webkitRelativePathonfile.meta, butuppyService.onBeforeFileAddedunconditionally recomputesmeta.relativePathfromfile.data.relativePath || file.data.webkitRelativePath. Neither of those was being set on the blob by the unzip handler. Result:meta.relativePathwas alwaysundefinedfor extracted files, soHandleUploadtreated them all as root-level and didn't create the nested directory tree.This regressed in opencloud-eu/web@
e1828e7f70(refactor: switch back to upstream uppy, 2024-12-20), which dropped thefile.meta.relativePath || file.meta.webkitRelativePathfallback inHandleUpload. From that point on, onlyfile.data.*was consulted, but the unzip handler wasn't writing there.Affected web versions
The fallback was removed in web@
e1828e7f70(2024-12-20) and first shipped in web v1.0.0 (2025-02-25). Module federation (the runtime mechanism that loads this extension) was added in web@f496f9a9f4(2026-03-24), first shipped in web v6.1.0. This unzip build pins@opencloud-eu/web-pkg: ^7.0.0, so it can only load into web v7.0.0+ at runtime. Every web version that can load this bundle has the regression. There is no host where the oldmeta.*fallback still works.Fix
Attach
relativePathdirectly to the data blob. This matches uppy's convention, the same one used byDropTarget.getDroppedFilesfor drag-and-drop folder uploads (web,packages/web-pkg/src/services/uppy/DropTarget/getDroppedFiles.ts:17).uppyServicenow picks it up, populatesmeta.relativePath, andHandleUploadcreates the nested directory tree as expected.Test
The e2e test (extended to assert the preserved subfolder structure for
data.zip) currently has to stayskippedbecause the OpenCloud rolling image bundles web v7.0.0, which is missing two prerequisite web fixes:useService<UppyService>('$uppyService')returns undefined when the unzip handler runs, the extract throws, and the catch shows "Failed to extract archive". This is the same reason the test was originally skipped.data.zipwraps its content indata/, which is the same name as the freshly-created extraction folder, so the dialog fires.Once a published OpenCloud image bundles a web that contains both, drop
test.skipand the merge-dialog dismissal block. Verified locally against an unbundled web build (override mounting../web/dist) that includes both PRs.Related Issue
Types of changes