mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
Also consider wrapped errors when checking for file IsNotExist errors
Fixes #10534
This commit is contained in:
9
cache/filecache/filecache_pruner.go
vendored
9
cache/filecache/filecache_pruner.go
vendored
@@ -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
|
||||
|
Reference in New Issue
Block a user