Skip to content

[Backport v2] fix(oci): skip digest-named directories during GC - #1588

Merged
TerryHowe merged 1 commit into
oras-project:v2from
jadhavgaurav:fix/gc-digest-dir-v2
Oct 15, 2026
Merged

TerryHowe merged 1 commit into
oras-project:v2from
jadhavgaurav:fix/gc-digest-dir-v2

Conversation

@jadhavgaurav

Copy link
Copy Markdown
Contributor

Backport of #1526 to v2. Fixes #1579.

Store.GC skipped directories under blobs/ but not under blobs/<alg>/. A directory whose name looks like a digest reached os.Remove, which fails on a non-empty directory and aborts GC.

Changes, matching #1526:

  • Skip directory entries in the inner blobs/<alg>/ loop.
  • Wrap the os.Remove error with the blob path.
  • Tests for empty and non-empty digest-named directories (left in place while unreachable blobs are still collected) and for the os.Remove error path.

Testing: the patch from #1526 applied cleanly to v2. With the source change reverted, TestStore_GCSkipsNonEmptyDigestNamedDirectory and TestStore_GCSkipsEmptyDigestNamedDirectory fail; with it, go test -race ./content/oci/..., go test ./..., go vet and gofmt pass.

Partially generated with Claude Code; tests run locally.

Backport of oras-project#1526 to v2. Store.GC skipped directories under blobs/ but not under blobs/<alg>/, so a directory named like a digest reached os.Remove, which fails on a non-empty directory and aborts GC. GC now skips those directories, and os.Remove errors include the blob path.

Fixes oras-project#1579

Signed-off-by: Gaurav Jadhav <[email protected]>
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.21%. Comparing base (03dcea5) to head (e47b3c1).

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #1588   +/-   ##
=======================================
  Coverage   89.21%   89.21%           
=======================================
  Files          64       64           
  Lines        4959     4961    +2     
=======================================
+ Hits         4424     4426    +2     
  Misses        526      526           
  Partials        9        9           

☔ 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.

@TerryHowe TerryHowe 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

@TerryHowe
TerryHowe merged commit 8883c85 into oras-project:v2 Oct 15, 2026
9 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

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.

2 participants