Repository navigation
fix(archive): keep nested folders in zip preview without directory entries - #3356
Open
Larrtroffen wants to merge 1 commit into
Open
Larrtroffen wants to merge 1 commit into
Larrtroffen wants to merge 1 commit into
Conversation
…tries Zips produced by Python zipfile/CI packers only contain file entries. Two places assumed explicit directory entries existed: - GenerateMetaTreeFromFolderTraversal could orphan a newly created parent chain when an ancestor was already known, so folders disappeared from the meta tree. - Zip.List only returned entries whose dirname equalled inner_path, so deeper paths and their parent folders were skipped. Attach every newly created ancestor until an existing node is reached, and synthesize first-level folders in List from the remaining path prefix. Adds a regression test for archives without directory records.
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.
Problem
Archive preview drops every sub-directory for zips that do not contain explicit directory entries — which is what
python -m zipfile, Python'szipfilemodule and many CI packers produce (only file entries such astask/environment/Dockerfile).For a 157-file archive with 10 top-level folders:
POST /api/fs/archive/metareturns only the files that sit directly in the first path segment; folders are missing.POST /api/fs/archive/listwithinner_path=/<top-folder>returns only those same files, so the folders can never be reached from the UI.Zips with explicit directory entries happen to work, which makes it look like a frontend issue.
Root cause
internal/archive/tool/helper.go,GenerateMetaTreeFromFolderTraversal: when a new folder chain is created and an ancestor already exists indirMap, the loop appends the child to its parent but breaks before attaching the newly created parent to the existing grandparent. The intermediate folder becomes an orphan.Minimal case:
a/exists (froma/README.txt), thena/b/c/file.txtarrives:bis created andcappended to it, butbis never appended toa.internal/archive/zip/zip.go,(*Zip).List: only looks at entries whosedirnameequalsinner_path; deeper paths are skipped and no intermediate directories are synthesized.Fix
Zip.List, match entries byinner_path + "/"prefix, and turn the next path segment into a synthesized folder object when the remainder still contains/.internal/archive/tool/helper_tree_test.gocovering a zip with no directory records.Verification
Before:
proj/submissing. After:proj/sub/deep/file.txtreachable;go test ./internal/archive/...passes.