Skip to content

Commit

Permalink
Fix podman disk issue: use proper index for blank layers (#277)
Browse files Browse the repository at this point in the history
Before, we were not dereferencing the index pointer when constructing the layer name,
resulting in layers named e.g., "blank_824644714416" when they should be "blank_0", "blank_1",
and so on.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano authored Jun 5, 2024
1 parent 47db70c commit 186f89b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions local/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ func (s *Store) addImageToTar(tw *tar.Writer, image v1.Image, withName string) e
blankIdx int
)
for _, layer := range layers {
layerName, err := s.addLayerToTar(tw, layer, &blankIdx)
layerName, err := s.addLayerToTar(tw, layer, blankIdx)
if err != nil {
return err
}
blankIdx++
layerPaths = append(layerPaths, layerName)
}

Expand All @@ -237,7 +238,7 @@ func (s *Store) addImageToTar(tw *tar.Writer, image v1.Image, withName string) e
return addTextToTar(tw, manifestJSON, "manifest.json")
}

func (s *Store) addLayerToTar(tw *tar.Writer, layer v1.Layer, blankIdx *int) (string, error) {
func (s *Store) addLayerToTar(tw *tar.Writer, layer v1.Layer, blankIdx int) (string, error) {
// If the layer is a previous image layer that hasn't been downloaded yet,
// cause ALL the previous image layers to be downloaded by grabbing the ReadCloser.
layerReader, err := layer.Uncompressed()
Expand All @@ -253,7 +254,6 @@ func (s *Store) addLayerToTar(tw *tar.Writer, layer v1.Layer, blankIdx *int) (st
}
if size == -1 { // it's a base (always empty) layer
layerName = fmt.Sprintf("blank_%d", blankIdx)
*blankIdx++
hdr := &tar.Header{Name: layerName, Mode: 0644, Size: 0}
return layerName, tw.WriteHeader(hdr)
}
Expand Down

0 comments on commit 186f89b

Please sign in to comment.