From 0d97b8e9da86978baddf9cada4be420998eedb6a Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 14 Apr 2026 07:25:05 +0200 Subject: [PATCH] chore: don't load settings twice for running `web` (#12111) - It's quite hard to determine when and why this was added here, my best guess is that this being the "oldest" subcommand at some point loading the configuration was not unified. Now it is unified in `prepareWorkPathAndCustomConf` which is run before any subcommand is run. It determines the work path, custom path and (custom) config and then loads the settings by calling `LoadCommonSettings`. - Between `prepareWorkPathAndCustomConf` being called and `serveInstalled` being called the `setting.CustomConf` is not changed. There was a possibility this being necessary for install page -> installed, but the install code already ensures that the new config is loaded and used. - Thus calling to load the settings again here is not necessary. There's a small possibility some settings loading code was written to only work after being loaded the second time. That's a bug that needs to be fixed, because all other subcommands does not load the settings twice and would see a different view of the settings in that case. I don't fear such code being present here. - Resolves forgejo/forgejo#11024 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12111 Reviewed-by: Mathieu Fenniak Co-authored-by: Gusted Co-committed-by: Gusted --- cmd/web.go | 2 -- modules/setting/setting.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/web.go b/cmd/web.go index 683b19c82a..4a2a1de1fe 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -164,8 +164,6 @@ func serveInstall(_ context.Context, ctx *cli.Command) error { } func serveInstalled(_ context.Context, ctx *cli.Command) error { - setting.InitCfgProvider(setting.CustomConf) - setting.LoadCommonSettings() setting.MustInstalled() showWebStartupMessage("Prepare to run web server") diff --git a/modules/setting/setting.go b/modules/setting/setting.go index fac6e54fb1..44dad1fab1 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -119,8 +119,8 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error { mustCurrentRunUserMatch(cfg) // it depends on the SSH config, only non-builtin SSH server requires this check - loadOAuth2From(cfg) loadSecurityFrom(cfg) + loadOAuth2From(cfg) if err := loadAttachmentFrom(cfg); err != nil { return err }