Merge pull request #2717 from dmcgowan/diff-set-uncompressed-label
Set uncompressed label on diff when already exists
This commit is contained in:
commit
3f5e6cdeaa
@ -41,6 +41,7 @@ type walkingDiff struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var emptyDesc = ocispec.Descriptor{}
|
var emptyDesc = ocispec.Descriptor{}
|
||||||
|
var uncompressed = "containerd.io/uncompressed"
|
||||||
|
|
||||||
// NewWalkingDiff is a generic implementation of diff.Comparer. The diff is
|
// NewWalkingDiff is a generic implementation of diff.Comparer. The diff is
|
||||||
// calculated by mounting both the upper and lower mount sets and walking the
|
// 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 {
|
if config.Labels == nil {
|
||||||
config.Labels = map[string]string{}
|
config.Labels = map[string]string{}
|
||||||
}
|
}
|
||||||
config.Labels["containerd.io/uncompressed"] = dgstr.Digest().String()
|
config.Labels[uncompressed] = dgstr.Digest().String()
|
||||||
} else {
|
} else {
|
||||||
if err = archive.WriteDiff(ctx, cw, lowerRoot, upperRoot); err != nil {
|
if err = archive.WriteDiff(ctx, cw, lowerRoot, upperRoot); err != nil {
|
||||||
return errors.Wrap(err, "failed to write diff")
|
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")
|
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{
|
ocidesc = ocispec.Descriptor{
|
||||||
MediaType: config.MediaType,
|
MediaType: config.MediaType,
|
||||||
Size: info.Size,
|
Size: info.Size,
|
||||||
|
Loading…
Reference in New Issue
Block a user