mirror of
https://github.com/go-gitea/gitea
synced 2025-08-11 03:58:20 +00:00
Backport #25395 by @wxiaoguang 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. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -89,8 +89,13 @@ func generateSaveInternalToken(rootCfg ConfigProvider) {
|
||||
}
|
||||
|
||||
InternalToken = token
|
||||
saveCfg, err := rootCfg.PrepareSaving()
|
||||
if err != nil {
|
||||
log.Fatal("Error saving internal token: %v", err)
|
||||
}
|
||||
rootCfg.Section("security").Key("INTERNAL_TOKEN").SetValue(token)
|
||||
if err := rootCfg.Save(); err != nil {
|
||||
saveCfg.Section("security").Key("INTERNAL_TOKEN").SetValue(token)
|
||||
if err = saveCfg.Save(); err != nil {
|
||||
log.Fatal("Error saving internal token: %v", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user