Skip to content

Commit

Permalink
Merge pull request containerd#9864 from hinshun/feature/import-compre…
Browse files Browse the repository at this point in the history
…ssed

Automatically decompress archives for transfer service import
  • Loading branch information
mxpv authored Mar 19, 2024
2 parents 9a4231d + 34c5458 commit 124456e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/transfer/archive/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/containerd/containerd/v2/core/images/archive"
"github.com/containerd/containerd/v2/core/streaming"
tstreaming "github.com/containerd/containerd/v2/core/transfer/streaming"
"github.com/containerd/containerd/v2/pkg/archive/compression"
"github.com/containerd/log"
)

Expand Down Expand Up @@ -64,7 +65,18 @@ func (iis *ImageImportStream) Import(ctx context.Context, store content.Store) (
if iis.forceCompress {
opts = append(opts, archive.WithImportCompression())
}
return archive.ImportIndex(ctx, store, iis.stream, opts...)

r := iis.stream
if iis.mediaType == "" {
d, err := compression.DecompressStream(iis.stream)
if err != nil {
return ocispec.Descriptor{}, err
}
defer d.Close()
r = d
}

return archive.ImportIndex(ctx, store, r, opts...)
}

func (iis *ImageImportStream) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error) {
Expand Down

0 comments on commit 124456e

Please sign in to comment.