summaryrefslogtreecommitdiffstats
path: root/models/lfs.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-12-11 12:37:04 +0800
committerLauris BH <lauris@nix.lv>2017-12-11 06:37:04 +0200
commitf2e20c81b66e6a937ecdb686f8d1011371433365 (patch)
tree490e5af82aefdd25de5d90225b083ecb3ed11e5f /models/lfs.go
parentc082c3bce35d6d5d829a1e516b9bbf45b6d49bdc (diff)
downloadgitea-f2e20c81b66e6a937ecdb686f8d1011371433365.tar.gz
gitea-f2e20c81b66e6a937ecdb686f8d1011371433365.zip
Refactor struct's time to remove unnecessary memory usage (#3142)
* refactor struct's time to remove unnecessary memory usage * use AsTimePtr simple code * fix tests * fix time compare * fix template on gpg * use AddDuration instead of Add
Diffstat (limited to 'models/lfs.go')
-rw-r--r--models/lfs.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/models/lfs.go b/models/lfs.go
index d6cdc68892..711e5b0494 100644
--- a/models/lfs.go
+++ b/models/lfs.go
@@ -2,18 +2,18 @@ package models
import (
"errors"
- "time"
+
+ "code.gitea.io/gitea/modules/util"
)
// LFSMetaObject stores metadata for LFS tracked files.
type LFSMetaObject struct {
- ID int64 `xorm:"pk autoincr"`
- Oid string `xorm:"UNIQUE(s) INDEX NOT NULL"`
- Size int64 `xorm:"NOT NULL"`
- RepositoryID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
- Existing bool `xorm:"-"`
- Created time.Time `xorm:"-"`
- CreatedUnix int64 `xorm:"created"`
+ ID int64 `xorm:"pk autoincr"`
+ Oid string `xorm:"UNIQUE(s) INDEX NOT NULL"`
+ Size int64 `xorm:"NOT NULL"`
+ RepositoryID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
+ Existing bool `xorm:"-"`
+ CreatedUnix util.TimeStamp `xorm:"created"`
}
// LFSTokenResponse defines the JSON structure in which the JWT token is stored.
@@ -105,8 +105,3 @@ func (repo *Repository) RemoveLFSMetaObjectByOid(oid string) error {
return sess.Commit()
}
-
-// AfterLoad stores the LFSMetaObject creation time in the database as local time.
-func (m *LFSMetaObject) AfterLoad() {
- m.Created = time.Unix(m.CreatedUnix, 0).Local()
-}