From 2e77424d9cc68aa101fabcdb3204ef5a3a1a8d12 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 15 Feb 2024 15:55:03 +0100 Subject: [PATCH] storage: move check for enable_partial_images to GetDiffer move the check for `enable_partial_images` to GetDiffer so that it doesn't attempt any operation if the feature is disabled. Signed-off-by: Giuseppe Scrivano --- pkg/chunked/storage_linux.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/chunked/storage_linux.go b/pkg/chunked/storage_linux.go index 7faccef1c1..f7e0c34929 100644 --- a/pkg/chunked/storage_linux.go +++ b/pkg/chunked/storage_linux.go @@ -241,6 +241,10 @@ func GetDiffer(ctx context.Context, store storage.Store, blobDigest digest.Diges return nil, err } + if !parseBooleanPullOption(&storeOpts, "enable_partial_images", true) { + return nil, errors.New("enable_partial_images not configured") + } + _, hasZstdChunkedTOC := annotations[internal.ManifestChecksumKey] _, hasEstargzTOC := annotations[estargz.TOCJSONDigestAnnotation] @@ -259,10 +263,6 @@ func GetDiffer(ctx context.Context, store storage.Store, blobDigest digest.Diges } func makeConvertFromRawDiffer(ctx context.Context, store storage.Store, blobDigest digest.Digest, blobSize int64, annotations map[string]string, iss ImageSourceSeekable, storeOpts *types.StoreOptions) (*chunkedDiffer, error) { - if !parseBooleanPullOption(storeOpts, "convert_images", false) { - return nil, errors.New("convert_images not configured") - } - layersCache, err := getLayersCache(store) if err != nil { return nil, err @@ -1701,10 +1701,6 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff UncompressedDigest: uncompressedDigest, } - if !parseBooleanPullOption(c.storeOpts, "enable_partial_images", true) { - return output, errors.New("enable_partial_images not configured") - } - // When the hard links deduplication is used, file attributes are ignored because setting them // modifies the source file as well. useHardLinks := parseBooleanPullOption(c.storeOpts, "use_hard_links", false)