diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-04-01 16:00:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 16:00:26 +0800 |
commit | 5b7466053d993685939da8623fb78e94e4ee0797 (patch) | |
tree | 896d786c4dc8b692dc1fbba61ee70173593dd1b9 /routers/install | |
parent | 89b9d42f083b1f83ee8fc3ba0feaaa7cf04ec05b (diff) | |
download | gitea-5b7466053d993685939da8623fb78e94e4ee0797.tar.gz gitea-5b7466053d993685939da8623fb78e94e4ee0797.zip |
Skip frontend ROOT_URL check on installation page, remove unnecessary global var (#19291)
Skip `checkAppUrl` message on installation page because the ROOT_URL is not determined yet
Move global var `supportedDbTypeNames` into `install.Init` as a local var
Diffstat (limited to 'routers/install')
-rw-r--r-- | routers/install/install.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/routers/install/install.go b/routers/install/install.go index 164ce68405..ec1719439f 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -42,20 +42,18 @@ const ( tplPostInstall base.TplName = "post-install" ) -var supportedDbTypeNames []map[string]string // use a slice to keep order -func getDbTypeNames() []map[string]string { - if supportedDbTypeNames == nil { - for _, t := range setting.SupportedDatabaseTypes { - supportedDbTypeNames = append(supportedDbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]}) - } +// getSupportedDbTypeNames returns a slice for supported database types and names. The slice is used to keep the order +func getSupportedDbTypeNames() (dbTypeNames []map[string]string) { + for _, t := range setting.SupportedDatabaseTypes { + dbTypeNames = append(dbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]}) } - return supportedDbTypeNames + return dbTypeNames } // Init prepare for rendering installation page func Init(next http.Handler) http.Handler { rnd := templates.HTMLRenderer() - + dbTypeNames := getSupportedDbTypeNames() return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { if setting.InstallLock { resp.Header().Add("Refresh", "1; url="+setting.AppURL+"user/login") @@ -74,7 +72,7 @@ func Init(next http.Handler) http.Handler { "i18n": locale, "Title": locale.Tr("install.install"), "PageIsInstall": true, - "DbTypeNames": getDbTypeNames(), + "DbTypeNames": dbTypeNames, "AllLangs": translation.AllLangs(), "PageStartTime": startTime, |