From 03f6be5702b3ccb360ebf3fd588ebe9cbf14f94e Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Tue, 16 Jun 2026 22:08:39 -0700 Subject: [PATCH] fix(storage): avoid double-prefixing rootDir for cache-relative blob records Guard cache path normalization so rootDir is joined only for truly cache-relative records. This prevents malformed paths like root/root/... when dstRecord already contains rootDir, avoiding stat failures and unnecessary cache churn. Signed-off-by: Ramkumar Chinchani --- pkg/storage/imagestore/imagestore.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/storage/imagestore/imagestore.go b/pkg/storage/imagestore/imagestore.go index a4d39c82..92cc4ca6 100644 --- a/pkg/storage/imagestore/imagestore.go +++ b/pkg/storage/imagestore/imagestore.go @@ -1519,7 +1519,7 @@ func (is *ImageStore) DedupeBlob(src string, dstDigest godigest.Digest, dstRepo // cache record exists, but due to GC and upgrades from older versions, // disk content and cache records may go out of sync - if is.cache.UsesRelativePaths() && !path.IsAbs(dstRecord) { + if is.cache.UsesRelativePaths() && !path.IsAbs(dstRecord) && !strings.HasPrefix(dstRecord, is.rootDir+"/") { dstRecord = path.Join(is.rootDir, dstRecord) } @@ -1545,7 +1545,7 @@ func (is *ImageStore) DedupeBlob(src string, dstDigest godigest.Digest, dstRepo return err } - if is.cache.UsesRelativePaths() && !path.IsAbs(updatedRecord) { + if is.cache.UsesRelativePaths() && !path.IsAbs(updatedRecord) && !strings.HasPrefix(updatedRecord, is.rootDir+"/") { updatedRecord = path.Join(is.rootDir, updatedRecord) } @@ -1775,7 +1775,7 @@ func (is *ImageStore) checkCacheBlob(digest godigest.Digest) (string, error) { return "", err } - if is.cache.UsesRelativePaths() && !path.IsAbs(dstRecord) { + if is.cache.UsesRelativePaths() && !path.IsAbs(dstRecord) && !strings.HasPrefix(dstRecord, is.rootDir+"/") { dstRecord = path.Join(is.rootDir, dstRecord) }