Skip to content

Commit

Permalink
Rename addBlobsUsedInIndex to countBlobsReferencedByIndex
Browse files Browse the repository at this point in the history
... and document it a bit better

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Sep 3, 2024
1 parent d8c1431 commit 0c12b6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions oci/layout/oci_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (ref ociReference) countBlobsForDescriptor(dest map[digest.Digest]int, desc
if err != nil {
return err
}
if err := ref.addBlobsUsedInIndex(dest, index, sharedBlobsDir); err != nil {
if err := ref.countBlobsReferencedByIndex(dest, index, sharedBlobsDir); err != nil {
return err
}
default:
Expand All @@ -77,8 +77,8 @@ func (ref ociReference) countBlobsForDescriptor(dest map[digest.Digest]int, desc
return nil
}

// Updates a map of digest with the usage count, so a blob that is referenced three times will have 3 in the map
func (ref ociReference) addBlobsUsedInIndex(destination map[digest.Digest]int, index *imgspecv1.Index, sharedBlobsDir string) error {
// countBlobsReferencedByIndex updates dest with usage counts of blobs required for index, EXCLUDING the index itself.
func (ref ociReference) countBlobsReferencedByIndex(destination map[digest.Digest]int, index *imgspecv1.Index, sharedBlobsDir string) error {
for _, descriptor := range index.Manifests {
if err := ref.countBlobsForDescriptor(destination, &descriptor, sharedBlobsDir); err != nil {
return err
Expand All @@ -95,7 +95,7 @@ func (ref ociReference) getBlobsToDelete(blobsUsedByDescriptorToDelete map[diges
return nil, err
}
blobsUsedInRootIndex := make(map[digest.Digest]int)
err = ref.addBlobsUsedInIndex(blobsUsedInRootIndex, rootIndex, sharedBlobsDir)
err = ref.countBlobsReferencedByIndex(blobsUsedInRootIndex, rootIndex, sharedBlobsDir)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0c12b6c

Please sign in to comment.