-
Notifications
You must be signed in to change notification settings - Fork 3
fix: delete orphaned digest directories when last tag is removed #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3501343
f6492de
5c91a8b
0f6b308
d5aeb5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,3 +288,32 @@ func deleteTag(p *paths.Paths, repository, tag string) error { | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| // countTagsForDigest counts how many tags in a repository point to a given digest | ||
| func countTagsForDigest(p *paths.Paths, repository, digestHex string) (int, error) { | ||
| tags, err := listTags(p, repository) | ||
| if err != nil { | ||
| return 0, err | ||
| } | ||
|
|
||
| count := 0 | ||
| for _, tag := range tags { | ||
| target, err := resolveTag(p, repository, tag) | ||
| if err != nil { | ||
| continue | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent error skip in tag count risks premature deletionMedium Severity
Additional Locations (1) |
||
| if target == digestHex { | ||
| count++ | ||
| } | ||
| } | ||
| return count, nil | ||
| } | ||
|
|
||
| // deleteDigest removes a digest directory and all its contents | ||
| func deleteDigest(p *paths.Paths, repository, digestHex string) error { | ||
| dir := digestDir(p, repository, digestHex) | ||
| if err := os.RemoveAll(dir); err != nil { | ||
| return fmt.Errorf("remove digest directory: %w", err) | ||
| } | ||
| return nil | ||
| } | ||


Uh oh!
There was an error while loading. Please reload this page.