diff --git a/image.go b/image.go index 62fba9de754a..14bfea91b9e1 100644 --- a/image.go +++ b/image.go @@ -170,26 +170,22 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error { chain = append(chain, layer.Diff.Digest) } - if unpacked { - desc, err := i.i.Config(ctx, cs, i.platform) - if err != nil { - return err - } + desc, err := i.i.Config(ctx, cs, i.platform) + if err != nil { + return err + } - rootfs := identity.ChainID(chain).String() + rootfs := identity.ChainID(chain).String() - cinfo := content.Info{ - Digest: desc.Digest, - Labels: map[string]string{ - fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootfs, - }, - } - if _, err := cs.Update(ctx, cinfo, fmt.Sprintf("labels.containerd.io/gc.ref.snapshot.%s", snapshotterName)); err != nil { - return err - } + cinfo := content.Info{ + Digest: desc.Digest, + Labels: map[string]string{ + fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootfs, + }, } - return nil + _, err = cs.Update(ctx, cinfo, fmt.Sprintf("labels.containerd.io/gc.ref.snapshot.%s", snapshotterName)) + return err } func (i *image) getLayers(ctx context.Context, platform platforms.MatchComparer) ([]rootfs.Layer, error) {