diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-10-05 09:08:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 09:08:19 +0800 |
commit | 9f8d59858af581a2c278a4896a301339991ece5b (patch) | |
tree | 577a395a442ccd9579dfd2726750301e6a934ef3 /routers/install/install.go | |
parent | 976d1760ac483a6f5fa8fa5ad24d94cae58497eb (diff) | |
download | gitea-9f8d59858af581a2c278a4896a301339991ece5b.tar.gz gitea-9f8d59858af581a2c278a4896a301339991ece5b.zip |
Refactor system setting (#27000)
This PR reduces the complexity of the system setting system.
It only needs one line to introduce a new option, and the option can be
used anywhere out-of-box.
It is still high-performant (and more performant) because the config
values are cached in the config system.
Diffstat (limited to 'routers/install/install.go')
-rw-r--r-- | routers/install/install.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/routers/install/install.go b/routers/install/install.go index 3eb16b9ce8..185e4bf6bf 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -430,15 +430,14 @@ func SubmitInstall(ctx *context.Context) { cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").SetValue(fmt.Sprint(form.MailNotify)) cfg.Section("server").Key("OFFLINE_MODE").SetValue(fmt.Sprint(form.OfflineMode)) - // if you are reinstalling, this maybe not right because of missing version - if err := system_model.SetSettingNoVersion(ctx, system_model.KeyPictureDisableGravatar, strconv.FormatBool(form.DisableGravatar)); err != nil { - ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) - return - } - if err := system_model.SetSettingNoVersion(ctx, system_model.KeyPictureEnableFederatedAvatar, strconv.FormatBool(form.EnableFederatedAvatar)); err != nil { + if err := system_model.SetSettings(ctx, map[string]string{ + setting.Config().Picture.DisableGravatar.DynKey(): strconv.FormatBool(form.DisableGravatar), + setting.Config().Picture.EnableFederatedAvatar.DynKey(): strconv.FormatBool(form.EnableFederatedAvatar), + }); err != nil { ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) return } + cfg.Section("openid").Key("ENABLE_OPENID_SIGNIN").SetValue(fmt.Sprint(form.EnableOpenIDSignIn)) cfg.Section("openid").Key("ENABLE_OPENID_SIGNUP").SetValue(fmt.Sprint(form.EnableOpenIDSignUp)) cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(fmt.Sprint(form.DisableRegistration)) |