Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix podman disk issue: use proper index for blank layers #277

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading