Skip to content

Commit 3f5e6cd

Browse files
Merge pull request #2717 from dmcgowan/diff-set-uncompressed-label
Set uncompressed label on diff when already exists
2 parents 50c020f + bb197dd commit 3f5e6cd

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)