From 87152f89ba313446fcf1c92ee40c404645c188f5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 24 Aug 2015 21:01:23 +0800 Subject: [PATCH] fix release created timezone issue --- gogs.go | 2 +- models/models.go | 4 +++- models/release.go | 9 +++++++++ templates/.VERSION | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gogs.go b/gogs.go index 8f3bb3adb..777aad68c 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.6.5.0820 Beta" +const APP_VER = "0.6.5.0824 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/models.go b/models/models.go index 7d02bb956..c14139194 100644 --- a/models/models.go +++ b/models/models.go @@ -133,7 +133,9 @@ func getEngine() (*xorm.Engine, error) { if !EnableSQLite3 { return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) } - os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) + if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil { + return nil, fmt.Errorf("Fail to create directories: %v", err) + } cnnstr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc" default: return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) diff --git a/models/release.go b/models/release.go index 012b6cc5c..027491d9d 100644 --- a/models/release.go +++ b/models/release.go @@ -10,6 +10,8 @@ import ( "strings" "time" + "github.com/go-xorm/xorm" + "github.com/gogits/gogs/modules/git" ) @@ -37,6 +39,13 @@ type Release struct { Created time.Time `xorm:"CREATED"` } +func (r *Release) AfterSet(colName string, _ xorm.Cell) { + switch colName { + case "created": + r.Created = regulateTimeZone(r.Created) + } +} + // IsReleaseExist returns true if release with given tag name already exists. func IsReleaseExist(repoId int64, tagName string) (bool, error) { if len(tagName) == 0 { diff --git a/templates/.VERSION b/templates/.VERSION index 53bfc6caf..5b133cfbe 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.6.5.0820 Beta \ No newline at end of file +0.6.5.0824 Beta \ No newline at end of file