diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-12-14 12:20:13 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-12-14 13:51:06 +0100 |
commit | ad2059878a8d6ace9669ccc5ff0a8d4e5811ad37 (patch) | |
tree | 34d88705ab22e5b54949a6ce48e028b1fc2ab7e6 /cache/filecache | |
parent | 87e898a17a52b5338bc9d554dd12b99a54aa2431 (diff) |
Also consider wrapped errors when checking for file IsNotExist errors
Fixes #10534
Diffstat (limited to 'cache/filecache')
-rw-r--r-- | cache/filecache/filecache_pruner.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cache/filecache/filecache_pruner.go b/cache/filecache/filecache_pruner.go index e5e571972..5734af199 100644 --- a/cache/filecache/filecache_pruner.go +++ b/cache/filecache/filecache_pruner.go @@ -18,6 +18,7 @@ import ( "io" "os" + "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/hugofs" "github.com/spf13/afero" @@ -36,7 +37,7 @@ func (c Caches) Prune() (int, error) { counter += count if err != nil { - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { continue } return counter, fmt.Errorf("failed to prune cache %q: %w", k, err) @@ -76,7 +77,7 @@ func (c *Cache) Prune(force bool) (int, error) { err = c.Fs.Remove(name) } - if err != nil && !os.IsNotExist(err) { + if err != nil && !herrors.IsNotExist(err) { return err } @@ -97,7 +98,7 @@ func (c *Cache) Prune(force bool) (int, error) { counter++ } - if err != nil && !os.IsNotExist(err) { + if err != nil && !herrors.IsNotExist(err) { return err } @@ -112,7 +113,7 @@ func (c *Cache) Prune(force bool) (int, error) { func (c *Cache) pruneRootDir(force bool) (int, error) { info, err := c.Fs.Stat(c.pruneAllRootDir) if err != nil { - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { return 0, nil } return 0, err |