diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-06-02 17:27:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 17:27:30 +0800 |
commit | de4a21fcb4476772c69c36d086549e89ed4dcf6c (patch) | |
tree | a8952b92bc6382daffc34178f5d6cc32cfea2efd /routers/install | |
parent | 7a5873335afb00dda5fa123fb023c88278e79deb (diff) | |
download | gitea-de4a21fcb4476772c69c36d086549e89ed4dcf6c.tar.gz gitea-de4a21fcb4476772c69c36d086549e89ed4dcf6c.zip |
Refactor INI package (first step) (#25024)
The INI package has many bugs and quirks, and in fact it is
unmaintained.
This PR is the first step for the INI package refactoring:
* Use Gitea's "config_provider" to provide INI access
* Deprecate the INI package by golangci.yml rule
Diffstat (limited to 'routers/install')
-rw-r--r-- | routers/install/install.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/routers/install/install.go b/routers/install/install.go index 4635cd7cb6..51ad6ec378 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -35,7 +35,6 @@ import ( "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/session" - "gopkg.in/ini.v1" ) const ( @@ -371,17 +370,11 @@ func SubmitInstall(ctx *context.Context) { } // Save settings. - cfg := ini.Empty() - isFile, err := util.IsFile(setting.CustomConf) + cfg, err := setting.NewConfigProviderFromFile(&setting.Options{CustomConf: setting.CustomConf, AllowEmpty: true}) if err != nil { - log.Error("Unable to check if %s is a file. Error: %v", setting.CustomConf, err) - } - if isFile { - // Keeps custom settings if there is already something. - if err = cfg.Append(setting.CustomConf); err != nil { - log.Error("Failed to load custom conf '%s': %v", setting.CustomConf, err) - } + log.Error("Failed to load custom conf '%s': %v", setting.CustomConf, err) } + cfg.Section("database").Key("DB_TYPE").SetValue(setting.Database.Type.String()) cfg.Section("database").Key("HOST").SetValue(setting.Database.Host) cfg.Section("database").Key("NAME").SetValue(setting.Database.Name) |