Do not return empty theme dirs - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 5f5fccbc36c1072150d1b665d9d9ef93a5401b82
DIR parent 4ddd5361c1ee9b8abbd1f1cb60395d0979127f03
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sat, 30 Jul 2016 16:21:57 +0200
Do not return empty theme dirs
This prevents reading data etc. from the root.
Fixes #2320
Diffstat:
M helpers/path.go | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
DIR diff --git a/helpers/path.go b/helpers/path.go
@@ -183,13 +183,15 @@ func GetThemeDataDirPath() (string, error) {
}
func getThemeDirPath(path string) (string, error) {
- var themeDir string
- if ThemeSet() {
- themeDir = filepath.Join(GetThemeDir(), path)
- if _, err := os.Stat(themeDir); os.IsNotExist(err) {
- return "", fmt.Errorf("Unable to find %s directory for theme %s in %s", path, viper.GetString("theme"), themeDir)
- }
+ if !ThemeSet() {
+ return "", errors.New("No theme set")
}
+
+ themeDir := filepath.Join(GetThemeDir(), path)
+ if _, err := os.Stat(themeDir); os.IsNotExist(err) {
+ return "", fmt.Errorf("Unable to find %s directory for theme %s in %s", path, viper.GetString("theme"), themeDir)
+ }
+
return themeDir, nil
}