From 1c9557d5435122a54a2d8a0649f74925dd1cd3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Fri, 15 Mar 2024 22:33:11 +0100 Subject: [PATCH] Detect zstd:chunked format in source blobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... instead of only treating it as zstd. Signed-off-by: Miloslav Trmač --- copy/compression.go | 10 ++++++++++ copy/single.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/copy/compression.go b/copy/compression.go index cfb4c8d107..fb5e1b174e 100644 --- a/copy/compression.go +++ b/copy/compression.go @@ -52,6 +52,16 @@ func blobPipelineDetectCompressionStep(stream *sourceStream, srcInfo types.BlobI } stream.reader = reader + if decompressor != nil && format.Name() == compressiontypes.ZstdAlgorithmName { + tocDigest, err := chunkedToc.GetTOCDigest(srcInfo.Annotations) + if err != nil { + return bpDetectCompressionStepData{}, err + } + if tocDigest != nil { + format = compression.ZstdChunked + } + + } res := bpDetectCompressionStepData{ isCompressed: decompressor != nil, format: format, diff --git a/copy/single.go b/copy/single.go index d70c928557..ba414a22d6 100644 --- a/copy/single.go +++ b/copy/single.go @@ -163,7 +163,7 @@ func (c *copier) copySingleImage(ctx context.Context, unparsedImage *image.Unpar if format == nil { format = defaultCompressionFormat } - if format.Name() == compression.ZstdChunked.Name() { + if format.Name() == compressiontypes.ZstdChunkedAlgorithmName { if ic.requireCompressionFormatMatch { return copySingleImageResult{}, errors.New("explicitly requested to combine zstd:chunked with encryption, which is not beneficial; use plain zstd instead") }