From 2362cf6832801405692e46eb9bd4992b34e84633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 18 Nov 2024 19:42:28 +0100 Subject: [PATCH] Tighten the conditions for storageImageSource.cachedManifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the value is set to a zero-byte value, use it, instead of trying to look for a value again / elsewhere. This should not make a difference in practice, a zero-length manifest is invalid anyway; so it's just a conceptual cleanup / a microoptimization. Signed-off-by: Miloslav Trmač --- storage/storage_src.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/storage_src.go b/storage/storage_src.go index 55788f8877..50dae54a27 100644 --- a/storage/storage_src.go +++ b/storage/storage_src.go @@ -247,7 +247,7 @@ func (s *storageImageSource) GetManifest(ctx context.Context, instanceDigest *di } return blob, manifest.GuessMIMEType(blob), err } - if len(s.cachedManifest) == 0 { + if s.cachedManifest == nil { // The manifest is stored as a big data item. // Prefer the manifest corresponding to the user-specified digest, if available. if s.imageRef.named != nil { @@ -267,7 +267,7 @@ func (s *storageImageSource) GetManifest(ctx context.Context, instanceDigest *di } // If the user did not specify a digest, or this is an old image stored before manifestBigDataKey was introduced, use the default manifest. // Note that the manifest may not match the expected digest, and that is likely to fail eventually, e.g. in c/image/image/UnparsedImage.Manifest(). - if len(s.cachedManifest) == 0 { + if s.cachedManifest == nil { cachedBlob, err := s.imageRef.transport.store.ImageBigData(s.image.ID, storage.ImageDigestBigDataKey) if err != nil { return nil, "", err