mirror of
https://github.com/project-zot/zot.git
synced 2026-06-18 05:28:07 +08:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user