Skip to content

Commit

Permalink
getSize: allow unknown uncompressed size
Browse files Browse the repository at this point in the history
Layers from additional layer store possibly doesn't know the uncompressed size
until it fully downloads the entire contents to the node.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
  • Loading branch information
ktock committed May 15, 2024
1 parent 92ab55a commit 76644c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions storage/storage_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,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 {
return nil, fmt.Errorf("uncompressed size for layer %q is unknown", layerID)
}

blobDigest := layer.UncompressedDigest
if blobDigest == "" {
Expand Down Expand Up @@ -453,9 +450,12 @@ func (s *storageImageSource) getSize() (int64, error) {
if err != nil {
return -1, err
}
if (layer.TOCDigest == "" && layer.UncompressedDigest == "") || layer.UncompressedSize < 0 {
if (layer.TOCDigest == "" && layer.UncompressedDigest == "") || (layer.TOCDigest == "" && layer.UncompressedSize < 0) {
return -1, fmt.Errorf("size for layer %q is unknown, failing getSize()", layerID)
}
if layer.UncompressedSize < 0 {
sum = 0
}
sum += layer.UncompressedSize
if layer.Parent == "" {
break
Expand Down

0 comments on commit 76644c2

Please sign in to comment.