@@ -19,6 +19,7 @@ import (
19
19
"code.gitea.io/gitea/modules/sync"
20
20
)
21
21
22
+ // MirrorQueue holds an UniqueQueue object of the mirror
22
23
var MirrorQueue = sync .NewUniqueQueue (setting .Repository .MirrorQueueLength )
23
24
24
25
// Mirror represents mirror information of a repository.
@@ -37,16 +38,19 @@ type Mirror struct {
37
38
address string `xorm:"-"`
38
39
}
39
40
41
+ // BeforeInsert will be invoked by XORM before inserting a record
40
42
func (m * Mirror ) BeforeInsert () {
41
43
m .UpdatedUnix = time .Now ().Unix ()
42
44
m .NextUpdateUnix = m .NextUpdate .Unix ()
43
45
}
44
46
47
+ // BeforeUpdate is invoked from XORM before updating this object.
45
48
func (m * Mirror ) BeforeUpdate () {
46
49
m .UpdatedUnix = time .Now ().Unix ()
47
50
m .NextUpdateUnix = m .NextUpdate .Unix ()
48
51
}
49
52
53
+ // AfterSet is invoked from XORM after setting the value of a field of this object.
50
54
func (m * Mirror ) AfterSet (colName string , _ xorm.Cell ) {
51
55
var err error
52
56
switch colName {
@@ -180,10 +184,12 @@ func updateMirror(e Engine, m *Mirror) error {
180
184
return err
181
185
}
182
186
187
+ // UpdateMirror updates the mirror
183
188
func UpdateMirror (m * Mirror ) error {
184
189
return updateMirror (x , m )
185
190
}
186
191
192
+ // DeleteMirrorByRepoID deletes a mirror by repoID
187
193
func DeleteMirrorByRepoID (repoID int64 ) error {
188
194
_ , err := x .Delete (& Mirror {RepoID : repoID })
189
195
return err
@@ -241,6 +247,7 @@ func SyncMirrors() {
241
247
}
242
248
}
243
249
250
+ // InitSyncMirrors initializes a go routine to sync the mirros
244
251
func InitSyncMirrors () {
245
252
go SyncMirrors ()
246
253
}
0 commit comments