detached 52cf0df

fix(registry): accumulate blob sizes into SpaceReclaimed during prune

commit
52cf0df949621ecd0cd703f4cb72ea670e9ce99e
author
brice · · 2026-03-27 18:36 UTC
parent
f5d3652
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +5 -3
M internal/usecase/images/service.go +3 -1
@@ -243,10 +243,12 @@ func (s *Service) PruneRegistry(ctx context.Context, keepLast int) (domain.Image
243243 if _, referenced := referencedDigests[digest]; referenced {
244244 continue
245245 }
246- if err := s.blobStorage.DeleteBlob(digest); err != nil {
246+ size, err := s.blobStorage.DeleteBlob(digest)
247+ if err != nil {
247248 return domain.ImagePruneReport{}, log.WrapErr(err, "failed to delete blob")
248249 }
249250 report.Registry.BlobsRemoved++
251+ report.Registry.SpaceReclaimed += size
250252 }
251253
252254 // Clean up stale uploads (abandoned push operations)
@@ -243,10 +243,12 @@ func (s *Service) PruneRegistry(ctx context.Context, keepLast int) (domain.Image
243 if _, referenced := referencedDigests[digest]; referenced {243 if _, referenced := referencedDigests[digest]; referenced {
244 continue244 continue
245 }245 }
246- if err := s.blobStorage.DeleteBlob(digest); err != nil {246+ size, err := s.blobStorage.DeleteBlob(digest)
247+ if err != nil {
247 return domain.ImagePruneReport{}, log.WrapErr(err, "failed to delete blob")248 return domain.ImagePruneReport{}, log.WrapErr(err, "failed to delete blob")
248 }249 }
249 report.Registry.BlobsRemoved++250 report.Registry.BlobsRemoved++
251+ report.Registry.SpaceReclaimed += size
250 }252 }
251 253
252 // Clean up stale uploads (abandoned push operations)254 // Clean up stale uploads (abandoned push operations)
M internal/usecase/images/service_test.go +2 -2
@@ -789,7 +789,7 @@ func (f *fakeBlobStorage) ListBlobs() ([]string, error) {
789789 return append([]string(nil), f.blobs...), nil
790790 }
791791
792-func (f *fakeBlobStorage) DeleteBlob(digest string) error {
792+func (f *fakeBlobStorage) DeleteBlob(digest string) (int64, error) {
793793 f.deletedBlobs = append(f.deletedBlobs, digest)
794794 for i, existing := range f.blobs {
795795 if existing != digest {
@@ -798,7 +798,7 @@ func (f *fakeBlobStorage) DeleteBlob(digest string) error {
798798 f.blobs = append(f.blobs[:i], f.blobs[i+1:]...)
799799 break
800800 }
801- return nil
801+ return 0, nil
802802 }
803803
804804 func (f *fakeBlobStorage) CleanupStaleUploads(_ time.Duration) (int, int64, error) {
@@ -789,7 +789,7 @@ func (f *fakeBlobStorage) ListBlobs() ([]string, error) {
789 return append([]string(nil), f.blobs...), nil789 return append([]string(nil), f.blobs...), nil
790 }790 }
791 791
792-func (f *fakeBlobStorage) DeleteBlob(digest string) error {792+func (f *fakeBlobStorage) DeleteBlob(digest string) (int64, error) {
793 f.deletedBlobs = append(f.deletedBlobs, digest)793 f.deletedBlobs = append(f.deletedBlobs, digest)
794 for i, existing := range f.blobs {794 for i, existing := range f.blobs {
795 if existing != digest {795 if existing != digest {
@@ -798,7 +798,7 @@ func (f *fakeBlobStorage) DeleteBlob(digest string) error {
798 f.blobs = append(f.blobs[:i], f.blobs[i+1:]...)798 f.blobs = append(f.blobs[:i], f.blobs[i+1:]...)
799 break799 break
800 }800 }
801- return nil801+ return 0, nil
802 }802 }
803 803
804 func (f *fakeBlobStorage) CleanupStaleUploads(_ time.Duration) (int, int64, error) {804 func (f *fakeBlobStorage) CleanupStaleUploads(_ time.Duration) (int, int64, error) {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close