提交 8767d1a1 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!49 support more compressed type when import tarball

Merge pull request !49 from wangfengtu/more_type
%global _version 2.0.0
%global _release 20200608.153239.gitf3fd7793
%global _release 20200619.162225.gitb2154cf4
Name: iSulad-img
Version: %{_version}
Release: %{_release}
......
From 835df1e959632ee3a21fd532ab7468611ac1f798 Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Fri, 19 Jun 2020 16:12:50 +0800
Subject: [PATCH] support more compressed type when import tarball
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
.../containers/image/tarball/tarball_src.go | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/vendor/github.com/containers/image/tarball/tarball_src.go b/vendor/github.com/containers/image/tarball/tarball_src.go
index 76e3e75..a3c5453 100644
--- a/vendor/github.com/containers/image/tarball/tarball_src.go
+++ b/vendor/github.com/containers/image/tarball/tarball_src.go
@@ -12,8 +12,8 @@ import (
"strings"
"time"
+ "github.com/containers/image/pkg/compression"
"github.com/containers/image/types"
- "github.com/klauspost/pgzip"
digest "github.com/opencontainers/go-digest"
imgspecs "github.com/opencontainers/image-spec/specs-go"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
@@ -67,23 +67,23 @@ func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.System
blobTime = fileinfo.ModTime()
}
- // Default to assuming the layer is compressed.
- layerType := imgspecv1.MediaTypeImageLayerGzip
-
// Set up to digest the file as it is.
blobIDdigester := digest.Canonical.Digester()
reader = io.TeeReader(reader, blobIDdigester.Hash())
// Set up to digest the file after we maybe decompress it.
diffIDdigester := digest.Canonical.Digester()
- uncompressed, err := pgzip.NewReader(reader)
- if err == nil {
+ uncompressed, iscompressed, err := compression.AutoDecompress(reader)
+ if err != nil {
+ return nil, fmt.Errorf("error decompress %q: %v", filename, err)
+ }
+ defer uncompressed.Close()
+ if iscompressed {
// It is compressed, so the diffID is the digest of the uncompressed version
reader = io.TeeReader(uncompressed, diffIDdigester.Hash())
} else {
// It is not compressed, so the diffID and the blobID are going to be the same
diffIDdigester = blobIDdigester
- layerType = imgspecv1.MediaTypeImageLayer
uncompressed = nil
}
// TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
@@ -91,9 +91,6 @@ func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.System
if err != nil {
return nil, fmt.Errorf("error reading %q: %v", filename, err)
}
- if uncompressed != nil {
- uncompressed.Close()
- }
// Grab our uncompressed and possibly-compressed digests and sizes.
filenames = append(filenames, filename)
@@ -102,7 +99,7 @@ func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.System
blobIDs = append(blobIDs, blobIDdigester.Digest())
blobSizes = append(blobSizes, blobSize)
blobTimes = append(blobTimes, blobTime)
- blobTypes = append(blobTypes, layerType)
+ blobTypes = append(blobTypes, imgspecv1.MediaTypeImageLayer)
}
// Build the rootfs and history for the configuration blob.
--
2.20.1
......@@ -54,3 +54,4 @@
0054-Change-copyright-from-Mulan-PSL-v1-to-Mulan-PSL-v2.patch
0055-Change-copyright-from-MulanPSL-to-MulanPSL2.patch
0056-make-sure-created-time-is-larger-or-equal-than-1970.patch
0057-support-more-compressed-type-when-import-tarball.patch
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册