Also consider wrapped errors when checking for file IsNotExist errors

Fixes #10534
This commit is contained in:
Bjørn Erik Pedersen
2022-12-14 12:20:13 +01:00
parent 87e898a17a
commit ad2059878a
21 changed files with 110 additions and 48 deletions

View File

@@ -24,6 +24,7 @@ import (
"strings"
"unicode"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/text"
"github.com/gohugoio/hugo/config"
@@ -378,7 +379,7 @@ func OpenFileForWriting(fs afero.Fs, filename string) (afero.File, error) {
// os.Create will create any new files with mode 0666 (before umask).
f, err := fs.Create(filename)
if err != nil {
if !os.IsNotExist(err) {
if !herrors.IsNotExist(err) {
return nil, err
}
if err = fs.MkdirAll(filepath.Dir(filename), 0777); err != nil { // before umask