From c700cdc39cdf6b8801b71b70f704d749650585fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 11 Sep 2016 19:59:07 +0200 Subject: [PATCH] Replace some leftover os.Stat with hugofs.Source --- commands/hugo.go | 4 ++-- helpers/path.go | 4 +++- source/filesystem.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/commands/hugo.go b/commands/hugo.go index 628219be3..339f7648a 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -408,7 +408,7 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error { themeDir := helpers.GetThemeDir() if themeDir != "" { - if _, err := os.Stat(themeDir); os.IsNotExist(err) { + if _, err := hugofs.Source().Stat(themeDir); os.IsNotExist(err) { return newSystemError("Unable to find theme Directory:", themeDir) } } @@ -593,7 +593,7 @@ func getDirList() []string { jww.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", path, err) return nil } - linkfi, err := os.Stat(link) + linkfi, err := hugofs.Source().Stat(link) if err != nil { jww.ERROR.Printf("Cannot stat '%s', error was: %s", link, err) return nil diff --git a/helpers/path.go b/helpers/path.go index 478512efa..b7e6f51a9 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -23,6 +23,8 @@ import ( "strings" "unicode" + "github.com/spf13/hugo/hugofs" + "github.com/spf13/afero" "github.com/spf13/viper" "golang.org/x/text/transform" @@ -194,7 +196,7 @@ func getThemeDirPath(path string) (string, error) { } themeDir := filepath.Join(GetThemeDir(), path) - if _, err := os.Stat(themeDir); os.IsNotExist(err) { + if _, err := hugofs.Source().Stat(themeDir); os.IsNotExist(err) { return "", fmt.Errorf("Unable to find %s directory for theme %s in %s", path, viper.GetString("theme"), themeDir) } diff --git a/source/filesystem.go b/source/filesystem.go index 82bcad6e6..5a6e331f1 100644 --- a/source/filesystem.go +++ b/source/filesystem.go @@ -119,7 +119,7 @@ func (f *Filesystem) shouldRead(filePath string, fi os.FileInfo) (bool, error) { jww.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", filePath, err) return false, nil } - linkfi, err := os.Stat(link) + linkfi, err := hugofs.Source().Stat(link) if err != nil { jww.ERROR.Printf("Cannot stat '%s', error was: %s", link, err) return false, nil