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 <rchincha.dev@gmail.com>
This commit is contained in:
Ramkumar Chinchani
2026-06-16 22:08:39 -07:00
parent 8a7a754236
commit 03f6be5702
+3 -3
View File
@@ -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)
}