diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-12-14 12:20:13 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-12-14 13:51:06 +0100 |
commit | ad2059878a8d6ace9669ccc5ff0a8d4e5811ad37 (patch) | |
tree | 34d88705ab22e5b54949a6ce48e028b1fc2ab7e6 /hugofs | |
parent | 87e898a17a52b5338bc9d554dd12b99a54aa2431 (diff) | |
download | hugo-ad2059878a8d6ace9669ccc5ff0a8d4e5811ad37.tar.gz hugo-ad2059878a8d6ace9669ccc5ff0a8d4e5811ad37.zip |
Also consider wrapped errors when checking for file IsNotExist errors
Fixes #10534
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/decorators.go | 3 | ||||
-rw-r--r-- | hugofs/rootmapping_fs.go | 3 | ||||
-rw-r--r-- | hugofs/slice_fs.go | 5 | ||||
-rw-r--r-- | hugofs/walk.go | 5 |
4 files changed, 10 insertions, 6 deletions
diff --git a/hugofs/decorators.go b/hugofs/decorators.go index 3762d753b..47b4266df 100644 --- a/hugofs/decorators.go +++ b/hugofs/decorators.go @@ -19,6 +19,7 @@ import ( "path/filepath" "strings" + "github.com/gohugoio/hugo/common/herrors" "github.com/spf13/afero" ) @@ -224,7 +225,7 @@ func (l *baseFileDecoratorFile) Readdir(c int) (ofi []os.FileInfo, err error) { // We need to resolve any symlink info. fi, _, err := lstatIfPossible(l.fs.Fs, filename) if err != nil { - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { continue } return nil, err diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go index 90df48f8c..a37e21a8b 100644 --- a/hugofs/rootmapping_fs.go +++ b/hugofs/rootmapping_fs.go @@ -19,6 +19,7 @@ import ( "path/filepath" "strings" + "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/hugofs/files" radix "github.com/armon/go-radix" @@ -45,7 +46,7 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) { fi, err := fs.Stat(rm.To) if err != nil { - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { continue } return nil, err diff --git a/hugofs/slice_fs.go b/hugofs/slice_fs.go index 7edaf7513..574a5cb5f 100644 --- a/hugofs/slice_fs.go +++ b/hugofs/slice_fs.go @@ -21,6 +21,7 @@ import ( "errors" + "github.com/gohugoio/hugo/common/herrors" "github.com/spf13/afero" ) @@ -161,7 +162,7 @@ func (fs *SliceFs) pickFirst(name string) (os.FileInfo, int, error) { return fi, i, nil } - if !os.IsNotExist(err) { + if !herrors.IsNotExist(err) { // Real error return nil, -1, err } @@ -175,7 +176,7 @@ func (fs *SliceFs) readDirs(name string, startIdx, count int) ([]os.FileInfo, er collect := func(lfs *FileMeta) ([]os.FileInfo, error) { d, err := lfs.Fs.Open(name) if err != nil { - if !os.IsNotExist(err) { + if !herrors.IsNotExist(err) { return nil, err } return nil, nil diff --git a/hugofs/walk.go b/hugofs/walk.go index 22a99402f..e847174c6 100644 --- a/hugofs/walk.go +++ b/hugofs/walk.go @@ -20,6 +20,7 @@ import ( "sort" "strings" + "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/common/loggers" "errors" @@ -118,7 +119,7 @@ func (w *Walkway) Walk() error { } else { info, _, err := lstatIfPossible(w.fs, w.root) if err != nil { - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { return nil } @@ -154,7 +155,7 @@ func (w *Walkway) checkErr(filename string, err error) bool { return true } - if os.IsNotExist(err) { + if herrors.IsNotExist(err) { // The file may be removed in process. // This may be a ERROR situation, but it is not possible // to determine as a general case. |