@@ -181,15 +181,10 @@ func (r *runtime) ImportImages(ctx context.Context, refs ...string) error {
181181
182182 for _ , ref := range refs {
183183 // fix: pull with unpack do not fetch missing contents
184- img , err := r .client .Fetch (ctx , ref , containerd .WithPlatformMatcher (r .platform ), containerd .WithResolver (r .resolver ))
184+ _ , err := r .client .Fetch (ctx , ref , containerd .WithPlatformMatcher (r .platform ), containerd .WithResolver (r .resolver ))
185185 if err != nil {
186186 return fmt .Errorf ("import %s: %w" , ref , err )
187187 }
188-
189- err = containerd .NewImageWithPlatform (r .client , img , r .platform ).Unpack (ctx , containerd .DefaultSnapshotter )
190- if err != nil {
191- return fmt .Errorf ("unpack %s: %w" , ref , err )
192- }
193188 }
194189 return nil
195190}
@@ -549,9 +544,10 @@ func withoutAnyMounts() oci.SpecOpts {
549544func withNewSnapshotAndConfig (img containerd.Image , configContent []model.ConfigFile ) containerd.NewContainerOpts {
550545 return func (ctx context.Context , client * containerd.Client , c * containers.Container ) error {
551546 var (
552- snapshotID = rand .String (10 )
553- data = toRawConfig (configContent )
554- descriptor = v1.Descriptor {
547+ snapshotID = rand .String (10 )
548+ snapshotterName = containerd .DefaultSnapshotter
549+ data = toRawConfig (configContent )
550+ descriptor = v1.Descriptor {
555551 MediaType : v1 .MediaTypeImageLayer ,
556552 Digest : digest .SHA256 .FromBytes (data ),
557553 Size : int64 (len (data )),
@@ -564,7 +560,17 @@ func withNewSnapshotAndConfig(img containerd.Image, configContent []model.Config
564560 return err
565561 }
566562
567- mounts , err := client .SnapshotService (containerd .DefaultSnapshotter ).Prepare (ctx , snapshotID , identity .ChainID (diffIDs ).String ())
563+ unpacked , err := img .IsUnpacked (ctx , snapshotterName )
564+ if err != nil {
565+ return err
566+ }
567+ if ! unpacked {
568+ if err := img .Unpack (ctx , snapshotterName ); err != nil {
569+ return err
570+ }
571+ }
572+
573+ mounts , err := client .SnapshotService (snapshotterName ).Prepare (ctx , snapshotID , identity .ChainID (diffIDs ).String ())
568574 if err != nil {
569575 return err
570576 }
0 commit comments