diff options
Diffstat (limited to 'modules/options/static.go')
-rw-r--r-- | modules/options/static.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/options/static.go b/modules/options/static.go index 39f56f42f4..ff1e6b2332 100644 --- a/modules/options/static.go +++ b/modules/options/static.go @@ -11,7 +11,9 @@ import ( "io/ioutil" "path" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "github.com/unknwon/com" ) @@ -31,8 +33,11 @@ func Dir(name string) ([]string, error) { ) customDir := path.Join(setting.CustomPath, "options", name) - - if com.IsDir(customDir) { + isDir, err := util.IsDir(customDir) + if err != nil { + return []string{}, fmt.Errorf("Failed to check if custom directory %s is a directory. %v", err) + } + if isDir { files, err := com.StatDir(customDir, true) if err != nil { @@ -100,7 +105,11 @@ func Labels(name string) ([]byte, error) { func fileFromDir(name string) ([]byte, error) { customPath := path.Join(setting.CustomPath, "options", name) - if com.IsFile(customPath) { + isFile, err := util.IsFile(customPath) + if err != nil { + log.Error("Unable to check if %s is a file. Error: %v", customPath, err) + } + if isFile { return ioutil.ReadFile(customPath) } |