diff options
Diffstat (limited to 'models/repo_mirror.go')
-rw-r--r-- | models/repo_mirror.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/models/repo_mirror.go b/models/repo_mirror.go index f52b3eb452..197889e19a 100644 --- a/models/repo_mirror.go +++ b/models/repo_mirror.go @@ -31,10 +31,8 @@ type Mirror struct { Interval time.Duration EnablePrune bool `xorm:"NOT NULL DEFAULT true"` - Updated time.Time `xorm:"-"` - UpdatedUnix int64 `xorm:"INDEX"` - NextUpdate time.Time `xorm:"-"` - NextUpdateUnix int64 `xorm:"INDEX"` + UpdatedUnix util.TimeStamp `xorm:"INDEX"` + NextUpdateUnix util.TimeStamp `xorm:"INDEX"` address string `xorm:"-"` } @@ -42,16 +40,8 @@ type Mirror struct { // BeforeInsert will be invoked by XORM before inserting a record func (m *Mirror) BeforeInsert() { if m != nil { - m.UpdatedUnix = time.Now().Unix() - m.NextUpdateUnix = m.NextUpdate.Unix() - } -} - -// BeforeUpdate is invoked from XORM before updating this object. -func (m *Mirror) BeforeUpdate() { - if m != nil { - m.UpdatedUnix = m.Updated.Unix() - m.NextUpdateUnix = m.NextUpdate.Unix() + m.UpdatedUnix = util.TimeStampNow() + m.NextUpdateUnix = util.TimeStampNow() } } @@ -66,14 +56,11 @@ func (m *Mirror) AfterLoad(session *xorm.Session) { if err != nil { log.Error(3, "getRepositoryByID[%d]: %v", m.ID, err) } - - m.Updated = time.Unix(m.UpdatedUnix, 0).Local() - m.NextUpdate = time.Unix(m.NextUpdateUnix, 0).Local() } // ScheduleNextUpdate calculates and sets next update time. func (m *Mirror) ScheduleNextUpdate() { - m.NextUpdate = time.Now().Add(m.Interval) + m.NextUpdateUnix = util.TimeStampNow().AddDuration(m.Interval) } func remoteAddress(repoPath string) (string, error) { @@ -193,7 +180,7 @@ func (m *Mirror) runSync() bool { } } - m.Updated = time.Now() + m.UpdatedUnix = util.TimeStampNow() return true } |