fix(config): ensure provided config path is used (#461)
This commit is contained in:
parent
714876e3d0
commit
346763caea
@ -117,9 +117,6 @@ func setupViper() {
|
|||||||
viper.BindPFlag("AlternativeRecaptcha", flag.Lookup("alternative-recaptcha"))
|
viper.BindPFlag("AlternativeRecaptcha", flag.Lookup("alternative-recaptcha"))
|
||||||
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
||||||
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
||||||
|
|
||||||
viper.SetConfigName("filebrowser")
|
|
||||||
viper.AddConfigPath(".")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion() {
|
||||||
@ -137,16 +134,15 @@ func main() {
|
|||||||
|
|
||||||
// Add a configuration file if set.
|
// Add a configuration file if set.
|
||||||
if config != "" {
|
if config != "" {
|
||||||
ext := filepath.Ext(config)
|
cfg := strings.TrimSuffix(config, filepath.Ext(config))
|
||||||
dir := filepath.Dir(config)
|
if dir := filepath.Dir(cfg); dir != "" {
|
||||||
config = strings.TrimSuffix(config, ext)
|
|
||||||
|
|
||||||
if dir != "" {
|
|
||||||
viper.AddConfigPath(dir)
|
viper.AddConfigPath(dir)
|
||||||
config = strings.TrimPrefix(config, dir)
|
cfg = strings.TrimPrefix(cfg, dir)
|
||||||
}
|
}
|
||||||
|
viper.SetConfigName(cfg)
|
||||||
viper.SetConfigName(config)
|
} else {
|
||||||
|
viper.SetConfigName("filebrowser")
|
||||||
|
viper.AddConfigPath(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read configuration from a file if exists.
|
// Read configuration from a file if exists.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user