Skip to content

Commit

Permalink
Don't modify a storage.Layer returned by c/storage
Browse files Browse the repository at this point in the history
This shouldn't matter in practice because the returned struct
happens to be a copy, but that's not promised by the API.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed May 20, 2024
1 parent c2327e4 commit 27516f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions storage/storage_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@ func (s *storageImageSource) LayerInfosForCopy(ctx context.Context, instanceDige
if err != nil {
return nil, fmt.Errorf("reading layer %q in image %q: %w", layerID, s.image.ID, err)
}
if layer.UncompressedSize < 0 {
layer.UncompressedSize = -1
}

blobDigest := layer.UncompressedDigest
if blobDigest == "" {
Expand All @@ -331,12 +328,16 @@ func (s *storageImageSource) LayerInfosForCopy(ctx context.Context, instanceDige
return nil, fmt.Errorf("parsing expected diffID %q for layer %q: %w", expectedDigest, layerID, err)
}
}
size := layer.UncompressedSize
if size < 0 {
size = -1
}
s.getBlobMutex.Lock()
s.getBlobMutexProtected.digestToLayerID[blobDigest] = layer.ID
s.getBlobMutex.Unlock()
blobInfo := types.BlobInfo{
Digest: blobDigest,
Size: layer.UncompressedSize,
Size: size,
MediaType: uncompressedLayerType,
}
physicalBlobInfos = append([]types.BlobInfo{blobInfo}, physicalBlobInfos...)
Expand Down

0 comments on commit 27516f3

Please sign in to comment.