From bb197ddc4702a3e1d55ddaa4181ff3aba8744877 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Mon, 15 Oct 2018 11:02:01 -0700 Subject: [PATCH] Set uncompressed label on diff when already exists Diff expects to set the uncompressed label on Commit, however if the blob already exists in the content store, no labels will get set, requiring an Update. Check if the uncompressed label is on the blob and set it if not. Signed-off-by: Derek McGowan --- diff/walking/differ.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/diff/walking/differ.go b/diff/walking/differ.go index f06aa016f..a45a5630b 100644 --- a/diff/walking/differ.go +++ b/diff/walking/differ.go @@ -41,6 +41,7 @@ type walkingDiff struct { } var emptyDesc = ocispec.Descriptor{} +var uncompressed = "containerd.io/uncompressed" // NewWalkingDiff is a generic implementation of diff.Comparer. The diff is // calculated by mounting both the upper and lower mount sets and walking the @@ -125,7 +126,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o if config.Labels == nil { config.Labels = map[string]string{} } - config.Labels["containerd.io/uncompressed"] = dgstr.Digest().String() + config.Labels[uncompressed] = dgstr.Digest().String() } else { if err = archive.WriteDiff(ctx, cw, lowerRoot, upperRoot); err != nil { return errors.Wrap(err, "failed to write diff") @@ -149,6 +150,14 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o return errors.Wrap(err, "failed to get info from content store") } + // Set uncompressed label if digest already existed without label + if _, ok := info.Labels[uncompressed]; !ok { + info.Labels[uncompressed] = config.Labels[uncompressed] + if _, err := s.store.Update(ctx, info, "labels."+uncompressed); err != nil { + return errors.Wrap(err, "error setting uncompressed label") + } + } + ocidesc = ocispec.Descriptor{ MediaType: config.MediaType, Size: info.Size,