aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting/setting.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-06-21 10:31:40 +0800
committerGitHub <noreply@github.com>2023-06-21 10:31:40 +0800
commitdf5cf5ddbd9099a121d5074a0b2a710fd71309fd (patch)
tree61844c68b8c38a2d24a90fc62c75aa0ef8522005 /modules/setting/setting.go
parent831db53c214f81e5eaf055716a42865007cb8123 (diff)
downloadgitea-df5cf5ddbd9099a121d5074a0b2a710fd71309fd.tar.gz
gitea-df5cf5ddbd9099a121d5074a0b2a710fd71309fd.zip
Avoid polluting config file when "save" (#25395)
That's a longstanding INI package problem: the "MustXxx" calls change the option values, and the following "Save" will save a lot of garbage options into the user's config file. Ideally we should refactor the INI package to a clear solution, but it's a huge work. A clear workaround is what this PR does: when "Save", load a clear INI instance and save it. Partially fix #25377, the "install" page needs more fine tunes.
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r--modules/setting/setting.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 539eb4b197..6eaddbe2b5 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -202,6 +202,7 @@ func Init(opts *Options) {
}
var err error
CfgProvider, err = NewConfigProviderFromFile(opts)
+ CfgProvider.DisableSaving() // do not allow saving the CfgProvider into file, it will be polluted by the "MustXxx" calls
if err != nil {
log.Fatal("newConfigProviderFromFile[%v]: %v", opts, err)
}
@@ -214,7 +215,7 @@ func Init(opts *Options) {
// loadCommonSettingsFrom loads common configurations from a configuration provider.
func loadCommonSettingsFrom(cfg ConfigProvider) error {
- // WARNNING: don't change the sequence except you know what you are doing.
+ // WARNING: don't change the sequence except you know what you are doing.
loadRunModeFrom(cfg)
loadLogGlobalFrom(cfg)
loadServerFrom(cfg)