mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-18 07:41:14 +01:00
models: fix xorm variable clobber (#12231)
NewTestEngine() takes a *xorm.Engine as its argument, and then immediately overwrites it. This fixes the model package to not take an unneeded variable, and changes the routers package to not create a nil *xorm.Engine that is immediately discarded by model.
This commit is contained in:
parent
48ad76c25e
commit
b49a195839
2 changed files with 2 additions and 4 deletions
|
@ -151,7 +151,7 @@ func getEngine() (*xorm.Engine, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTestEngine sets a new test xorm.Engine
|
// NewTestEngine sets a new test xorm.Engine
|
||||||
func NewTestEngine(x *xorm.Engine) (err error) {
|
func NewTestEngine() (err error) {
|
||||||
x, err = getEngine()
|
x, err = getEngine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Connect to database: %v", err)
|
return fmt.Errorf("Connect to database: %v", err)
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
|
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
"gopkg.in/ini.v1"
|
"gopkg.in/ini.v1"
|
||||||
"xorm.io/xorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -161,8 +160,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set test engine.
|
// Set test engine.
|
||||||
var x *xorm.Engine
|
if err = models.NewTestEngine(); err != nil {
|
||||||
if err = models.NewTestEngine(x); err != nil {
|
|
||||||
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
|
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
|
||||||
ctx.Data["Err_DbType"] = true
|
ctx.Data["Err_DbType"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://docs.gitea.io/en-us/install-from-binary/"), tplInstall, &form)
|
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://docs.gitea.io/en-us/install-from-binary/"), tplInstall, &form)
|
||||||
|
|
Loading…
Reference in a new issue