MirrorUpdate checks and updates mirror repositories.
()
| 359 | |
| 360 | // MirrorUpdate checks and updates mirror repositories. |
| 361 | func MirrorUpdate() { |
| 362 | if taskStatusTable.IsRunning(taskNameMirrorUpdate) { |
| 363 | return |
| 364 | } |
| 365 | taskStatusTable.Start(taskNameMirrorUpdate) |
| 366 | defer taskStatusTable.Stop(taskNameMirrorUpdate) |
| 367 | |
| 368 | log.Trace("Doing: MirrorUpdate") |
| 369 | |
| 370 | if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean any) error { |
| 371 | m := bean.(*Mirror) |
| 372 | if m.Repo == nil { |
| 373 | log.Error("Disconnected mirror repository found: %d", m.ID) |
| 374 | return nil |
| 375 | } |
| 376 | |
| 377 | MirrorQueue.Add(m.RepoID) |
| 378 | return nil |
| 379 | }); err != nil { |
| 380 | log.Error("MirrorUpdate: %v", err) |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | // SyncMirrors checks and syncs mirrors. |
| 385 | // TODO: sync more mirrors at same time. |