diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-04-25 23:06:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 23:06:39 +0800 |
commit | 5cf7da63ee74939595b8800787dcdb4c7290fa4f (patch) | |
tree | 39f6c9c6e2a0e78e63949b9299f52a8954abe0bc /cmd | |
parent | 56d4893b2a996da6388801c9c8ff16b9b588ad55 (diff) | |
download | gitea-5cf7da63ee74939595b8800787dcdb4c7290fa4f.tar.gz gitea-5cf7da63ee74939595b8800787dcdb4c7290fa4f.zip |
Refactor config provider (#24245)
This PR introduces more abstract about `ConfigProvider` and hides more `ini` references.
---------
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/web.go b/cmd/web.go index 11620c6b00..e451cf7dfa 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -24,7 +24,6 @@ import ( "github.com/felixge/fgprof" "github.com/urfave/cli" - ini "gopkg.in/ini.v1" ) // PIDFile could be set from build tag @@ -223,9 +222,10 @@ func setPort(port string) error { defaultLocalURL += ":" + setting.HTTPPort + "/" // Save LOCAL_ROOT_URL if port changed - setting.CreateOrAppendToCustomConf("server.LOCAL_ROOT_URL", func(cfg *ini.File) { - cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL) - }) + setting.CfgProvider.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL) + if err := setting.CfgProvider.Save(); err != nil { + return fmt.Errorf("Failed to save config file: %v", err) + } } return nil } |