Skip to content

Commit bb197dd

Browse files
committed
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 <[email protected]>
1 parent 50c020f commit bb197dd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

diff/walking/differ.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type walkingDiff struct {
4141
}
4242

4343
var emptyDesc = ocispec.Descriptor{}
44+
var uncompressed = "containerd.io/uncompressed"
4445

4546
// NewWalkingDiff is a generic implementation of diff.Comparer. The diff is
4647
// 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
125126
if config.Labels == nil {
126127
config.Labels = map[string]string{}
127128
}
128-
config.Labels["containerd.io/uncompressed"] = dgstr.Digest().String()
129+
config.Labels[uncompressed] = dgstr.Digest().String()
129130
} else {
130131
if err = archive.WriteDiff(ctx, cw, lowerRoot, upperRoot); err != nil {
131132
return errors.Wrap(err, "failed to write diff")
@@ -149,6 +150,14 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
149150
return errors.Wrap(err, "failed to get info from content store")
150151
}
151152

153+
// Set uncompressed label if digest already existed without label
154+
if _, ok := info.Labels[uncompressed]; !ok {
155+
info.Labels[uncompressed] = config.Labels[uncompressed]
156+
if _, err := s.store.Update(ctx, info, "labels."+uncompressed); err != nil {
157+
return errors.Wrap(err, "error setting uncompressed label")
158+
}
159+
}
160+
152161
ocidesc = ocispec.Descriptor{
153162
MediaType: config.MediaType,
154163
Size: info.Size,

0 commit comments

Comments
 (0)