|
|
@ -107,12 +107,14 @@ func DeleteMirrorByRepoID(repoID int64) error {
|
|
|
|
|
|
|
|
|
|
|
|
// MirrorsIterate iterates all mirror repositories.
|
|
|
|
// MirrorsIterate iterates all mirror repositories.
|
|
|
|
func MirrorsIterate(limit int, f func(idx int, bean interface{}) error) error {
|
|
|
|
func MirrorsIterate(limit int, f func(idx int, bean interface{}) error) error {
|
|
|
|
return db.GetEngine(db.DefaultContext).
|
|
|
|
sess := db.GetEngine(db.DefaultContext).
|
|
|
|
Where("next_update_unix<=?", time.Now().Unix()).
|
|
|
|
Where("next_update_unix<=?", time.Now().Unix()).
|
|
|
|
And("next_update_unix!=0").
|
|
|
|
And("next_update_unix!=0").
|
|
|
|
OrderBy("updated_unix ASC").
|
|
|
|
OrderBy("updated_unix ASC")
|
|
|
|
Limit(limit).
|
|
|
|
if limit > 0 {
|
|
|
|
Iterate(new(Mirror), f)
|
|
|
|
sess = sess.Limit(limit)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Iterate(new(Mirror), f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// InsertMirror inserts a mirror to database
|
|
|
|
// InsertMirror inserts a mirror to database
|
|
|
|