Skip to content

Commit

Permalink
Fix podman disk issue: use proper index for blank layers
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 <[email protected]>
  • Loading branch information
natalieparellano committed Jun 4, 2024
1 parent 4af8786 commit 307c8fd
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 @@ -216,10 +216,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 @@ -236,7 +237,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 @@ -252,7 +253,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 307c8fd

Please sign in to comment.