Skip to content

Commit

Permalink
Automatically decompress archives for transfer service import
Browse files Browse the repository at this point in the history
Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
  • Loading branch information
hinshun committed Mar 23, 2024
1 parent be5ec97 commit 2aec524
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/transfer/archive/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"

transferapi "github.com/containerd/containerd/api/types/transfer"
"github.com/containerd/containerd/archive/compression"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images/archive"
"github.com/containerd/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 2aec524

Please sign in to comment.