Skip to content

archive: Avoid duplicate implied-parent checks - #113

Merged
thaJeztah merged 2 commits into
moby:mainfrom
vvoland:avoid-parent-dup
Aug 14, 2026
Merged

archive: Avoid duplicate implied-parent checks#113
thaJeztah merged 2 commits into
moby:mainfrom
vvoland:avoid-parent-dup

Conversation

@vvoland

@vvoland vvoland commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

resolveArchivePath already checks whether an entry’s parent exists before createImpliedDirectories checks it again. Reuse that result for the current entry to avoid the duplicate lookup.

Unlike #112, this approach does not persist or mutate state across archive entries. It therefore needs no cache updates or invalidation.

Each entry uses the result from its own path resolution, so the next entry always observes the current filesystem state.

This provides the same optimization with less state and simpler invalidation semantics.

vvoland and others added 2 commits August 13, 2026 14:54
Represent the result of resolveArchivePath as a resolvedArchivePath so
callers can consume path-resolution details without adding parallel
return values. Update existing callers to use the resolved path without
changing extraction behavior.

Signed-off-by: Paweł Gronowski <git@grono.dev>
resolveArchivePath already checks each entry's parent before
createImpliedDirectories checks the same path again. Archives containing
many files therefore perform a redundant filesystem lookup for every
entry whose parent already exists.

Record that observation in resolvedArchivePath and reuse it only while
processing the current entry. This removes the duplicate lookup without
caching filesystem state across entries, so a parent removed during
extraction is observed and recreated for the next entry.

Co-authored-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: Paweł Gronowski <git@grono.dev>
@codecov-commenter

codecov-commenter commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.38%. Comparing base (e738eed) to head (1de6a88).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
archive.go 70.58% 4 Missing and 1 partial ⚠️
diff.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
+ Coverage   65.25%   65.38%   +0.13%     
==========================================
  Files          46       46              
  Lines        2377     2389      +12     
==========================================
+ Hits         1551     1562      +11     
+ Misses        606      605       -1     
- Partials      220      222       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@crazy-max crazy-max left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes looks better

@vvoland
vvoland requested a review from thaJeztah August 13, 2026 14:23
@vvoland vvoland self-assigned this Aug 13, 2026

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
thaJeztah merged commit 29f792a into moby:main Aug 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants