dedupe: stat blob path before creating link

This commit is contained in:
Shivam Mishra
2021-07-20 14:04:10 -07:00
committed by Ramkumar Chinchani
parent f10c174c0e
commit 53b5fa6493
7 changed files with 146 additions and 4 deletions
+6 -4
View File
@@ -51,6 +51,12 @@ func NewCache(rootDir string, name string, log zlog.Logger) *Cache {
}
func (c *Cache) PutBlob(digest string, path string) error {
if path == "" {
c.log.Error().Err(errors.ErrEmptyValue).Str("digest", digest).Msg("empty path provided")
return errors.ErrEmptyValue
}
// use only relative (to rootDir) paths on blobs
relp, err := filepath.Rel(c.rootDir, path)
if err != nil {
@@ -109,10 +115,6 @@ func (c *Cache) GetBlob(digest string) (string, error) {
return "", err
}
if len(blobPath.String()) == 0 {
return "", nil
}
return blobPath.String(), nil
}