diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index 2cdf4e394..230ed5826 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -88,7 +88,7 @@ func main() { } func runEnvironmentToIni(c *cli.Context) error { - setting.InitWorkPathAndCommonConfig(os.Getenv, setting.ArgWorkPathAndCustomConf{ + setting.InitWorkPathAndCfgProvider(os.Getenv, setting.ArgWorkPathAndCustomConf{ WorkPath: c.String("work-path"), CustomPath: c.String("custom-path"), CustomConf: c.String("config"), diff --git a/modules/setting/path.go b/modules/setting/path.go index 91bb2e9bb..163f1d159 100644 --- a/modules/setting/path.go +++ b/modules/setting/path.go @@ -89,6 +89,12 @@ func (s *stringWithDefault) Set(v string) { // InitWorkPathAndCommonConfig will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf and load common settings, func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) { + InitWorkPathAndCfgProvider(getEnvFn, args) + LoadCommonSettings() +} + +// InitWorkPathAndCfgProvider will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf +func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) { tryAbsPath := func(paths ...string) string { s := paths[len(paths)-1] for i := len(paths) - 2; i >= 0; i-- { @@ -186,6 +192,4 @@ func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWork AppWorkPath = tmpWorkPath.Value CustomPath = tmpCustomPath.Value CustomConf = tmpCustomConf.Value - - LoadCommonSettings() }