summaryrefslogtreecommitdiff
path: root/crawler/config.go
diff options
context:
space:
mode:
authorhorus2018-02-21 01:27:06 +0100
committerhorus2018-02-21 01:30:06 +0100
commit2cb42642b670d2b526a8afe16dead096738be094 (patch)
tree963e4de66480cdecb475fbc7bb308a8b369446f1 /crawler/config.go
parentdd89c6608b213bfa72f5c1cb77d33f805b2b3bfa (diff)
downloadalkobote-2cb42642b670d2b526a8afe16dead096738be094.tar.gz
Prevents panic when passing a non-existent path as config file. (crawler)
Diffstat (limited to 'crawler/config.go')
-rw-r--r--crawler/config.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/crawler/config.go b/crawler/config.go
index 20f8d13..9ee95b7 100644
--- a/crawler/config.go
+++ b/crawler/config.go
@@ -52,12 +52,17 @@ func (c *Config) parseConfig(configFile string) {
viper.AddConfigPath("$HOME/alkobote.de/")
} else {
stat, err := os.Stat(configFile)
- if stat.IsDir() || os.IsNotExist(err) {
+ if os.IsNotExist(err) {
// provided config file does not exist, so we add the path instead
viper.AddConfigPath(configFile)
- } else {
+ } else if err == nil && stat.IsDir() {
+ viper.AddConfigPath(configFile)
+ } else if err == nil {
// directly sets the config file
viper.SetConfigFile(configFile)
+ } else {
+ Warn(err, "config.go: os.Stat("+configFile+")")
+ viper.AddConfigPath(configFile)
}
}