fix(downloader): order DiskCache.Get checks for overlayfs empty dirs

Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
pull/32113/head
Sumit Solanki 20 hours ago
parent 0752c1f5b5
commit 6620fec5d1

@ -59,15 +59,17 @@ func (c *DiskCache) Get(key [sha256.Size]byte, cacheType string) (string, error)
if err != nil {
return "", err
}
// Empty files treated as not exist because there is no content.
if fi.Size() == 0 {
return p, os.ErrNotExist
}
// directories should never happen unless something outside helm is operating
// on this content.
if fi.IsDir() {
return p, errors.New("is a directory")
}
// Empty files treated as not exist because there is no content.
// IsDir must be checked first: some filesystems (e.g. overlay) report
// directory size as 0.
if fi.Size() == 0 {
return p, os.ErrNotExist
}
return p, nil
}

Loading…
Cancel
Save