Skip to content

Commit

Permalink
layerStore.Put(): update digest-based indexes when creating from temp…
Browse files Browse the repository at this point in the history
…lates

When we're creating a layer using another layer as a template, add the
new layer's uncompressed and compressed digest to the maps we use to
index layers using those digests.

When we forgot to do that, searching for a layer by either would still
turn up the original template, so this didn't really break anything.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
  • Loading branch information
nalind committed Apr 18, 2022
1 parent 861436b commit 2de654b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,14 @@ func (r *layerStore) Put(id string, parentLayer *Layer, names []string, mountLab
return nil, -1, err
}
delete(layer.Flags, incompleteFlag)
} else {
// applyDiffWithOptions in the `diff != nil` case handles this bit for us
if layer.CompressedDigest != "" {
r.bycompressedsum[layer.CompressedDigest] = append(r.bycompressedsum[layer.CompressedDigest], layer.ID)
}
if layer.UncompressedDigest != "" {
r.byuncompressedsum[layer.UncompressedDigest] = append(r.byuncompressedsum[layer.UncompressedDigest], layer.ID)
}
}
err = r.Save()
if err != nil {
Expand Down

0 comments on commit 2de654b

Please sign in to comment.