Skip to content

Commit 124456e

Browse files
authored
Merge pull request containerd#9864 from hinshun/feature/import-compressed
Automatically decompress archives for transfer service import
2 parents 9a4231d + 34c5458 commit 124456e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

core/transfer/archive/importer.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/containerd/containerd/v2/core/images/archive"
2929
"github.com/containerd/containerd/v2/core/streaming"
3030
tstreaming "github.com/containerd/containerd/v2/core/transfer/streaming"
31+
"github.com/containerd/containerd/v2/pkg/archive/compression"
3132
"github.com/containerd/log"
3233
)
3334

@@ -64,7 +65,18 @@ func (iis *ImageImportStream) Import(ctx context.Context, store content.Store) (
6465
if iis.forceCompress {
6566
opts = append(opts, archive.WithImportCompression())
6667
}
67-
return archive.ImportIndex(ctx, store, iis.stream, opts...)
68+
69+
r := iis.stream
70+
if iis.mediaType == "" {
71+
d, err := compression.DecompressStream(iis.stream)
72+
if err != nil {
73+
return ocispec.Descriptor{}, err
74+
}
75+
defer d.Close()
76+
r = d
77+
}
78+
79+
return archive.ImportIndex(ctx, store, r, opts...)
6880
}
6981

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

0 commit comments

Comments
 (0)