diff options
author | Bwko <bouwko@gmail.com> | 2016-11-26 01:30:21 +0100 |
---|---|---|
committer | Bwko <bouwko@gmail.com> | 2016-11-26 11:23:55 +0100 |
commit | 7bf7042013f7c78ceb581e9bf30ee1cee2e8a0bc (patch) | |
tree | 6644df68c63ba65b5cd97cb857aba370f55d631b /models/repo_mirror.go | |
parent | 0a76d260fa16764ab66bf1623b4cd9e9adfdac27 (diff) | |
download | gitea-7bf7042013f7c78ceb581e9bf30ee1cee2e8a0bc.tar.gz gitea-7bf7042013f7c78ceb581e9bf30ee1cee2e8a0bc.zip |
Lint models/repo_mirror.go
Diffstat (limited to 'models/repo_mirror.go')
-rw-r--r-- | models/repo_mirror.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/models/repo_mirror.go b/models/repo_mirror.go index fceffd43b7..23cbedaa0c 100644 --- a/models/repo_mirror.go +++ b/models/repo_mirror.go @@ -19,6 +19,7 @@ import ( "code.gitea.io/gitea/modules/sync" ) +// MirrorQueue holds an UniqueQueue object of the mirror var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength) // Mirror represents mirror information of a repository. @@ -37,16 +38,19 @@ type Mirror struct { address string `xorm:"-"` } +// BeforeInsert will be invoked by XORM before inserting a record func (m *Mirror) BeforeInsert() { m.UpdatedUnix = time.Now().Unix() m.NextUpdateUnix = m.NextUpdate.Unix() } +// BeforeUpdate is invoked from XORM before updating this object. func (m *Mirror) BeforeUpdate() { m.UpdatedUnix = time.Now().Unix() m.NextUpdateUnix = m.NextUpdate.Unix() } +// AfterSet is invoked from XORM after setting the value of a field of this object. func (m *Mirror) AfterSet(colName string, _ xorm.Cell) { var err error switch colName { @@ -180,10 +184,12 @@ func updateMirror(e Engine, m *Mirror) error { return err } +// UpdateMirror updates the mirror func UpdateMirror(m *Mirror) error { return updateMirror(x, m) } +// DeleteMirrorByRepoID deletes a mirror by repoID func DeleteMirrorByRepoID(repoID int64) error { _, err := x.Delete(&Mirror{RepoID: repoID}) return err @@ -241,6 +247,7 @@ func SyncMirrors() { } } +// InitSyncMirrors initializes a go routine to sync the mirros func InitSyncMirrors() { go SyncMirrors() } |