diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-01 18:53:41 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-01 18:53:41 -0400 |
commit | 100cd181bcc9fc46981cc2a4b88c05ad459fbc8f (patch) | |
tree | 2b2a8f07fa2760721e9418c39c51d751618ada5a /models | |
parent | 03c2468c2fa68e5b3c5cb6c498a155e7d725ccdb (diff) | |
download | gitea-100cd181bcc9fc46981cc2a4b88c05ad459fbc8f.tar.gz gitea-100cd181bcc9fc46981cc2a4b88c05ad459fbc8f.zip |
Add router log config option
Diffstat (limited to 'models')
-rw-r--r-- | models/models.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/models/models.go b/models/models.go index 8e8835ab51..059435f15f 100644 --- a/models/models.go +++ b/models/models.go @@ -58,10 +58,10 @@ func NewTestEngine(x *xorm.Engine) (err error) { case "postgres": var host, port = "127.0.0.1", "5432" fields := strings.Split(DbCfg.Host, ":") - if len(fields) > 0 { + if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 { host = fields[0] } - if len(fields) > 1 { + if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } cnnstr := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", @@ -91,10 +91,10 @@ func SetEngine() (err error) { case "postgres": var host, port = "127.0.0.1", "5432" fields := strings.Split(DbCfg.Host, ":") - if len(fields) > 0 { + if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 { host = fields[0] } - if len(fields) > 1 { + if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } orm, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", |