Skip to content

Commit d2ca021

Browse files
authored
Touch mirrors on even on fail to update (#19217)
* Touch mirrors on even on fail to update If a mirror fails to be synchronised it should be pushed to the bottom of the queue of the awaiting mirrors to be synchronised. At present if there LIMIT number of broken mirrors they can effectively prevent all other mirrors from being synchronized as their last_updated time will remain earlier than other mirrors. Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent c29fbc6 commit d2ca021

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

models/repo/mirror.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package repo
77

88
import (
9+
"context"
910
"errors"
1011
"fmt"
1112
"time"
@@ -113,6 +114,13 @@ func UpdateMirror(m *Mirror) error {
113114
return updateMirror(db.GetEngine(db.DefaultContext), m)
114115
}
115116

117+
// TouchMirror updates the mirror updatedUnix
118+
func TouchMirror(ctx context.Context, m *Mirror) error {
119+
m.UpdatedUnix = timeutil.TimeStampNow()
120+
_, err := db.GetEngine(ctx).ID(m.ID).Cols("updated_unix").Update(m)
121+
return err
122+
}
123+
116124
// DeleteMirrorByRepoID deletes a mirror by repoID
117125
func DeleteMirrorByRepoID(repoID int64) error {
118126
_, err := db.GetEngine(db.DefaultContext).Delete(&Mirror{RepoID: repoID})

services/mirror/mirror_pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
411411
log.Trace("SyncMirrors [repo: %-v]: Running Sync", m.Repo)
412412
results, ok := runSync(ctx, m)
413413
if !ok {
414+
if err = repo_model.TouchMirror(ctx, m); err != nil {
415+
log.Error("SyncMirrors [repo: %-v]: failed to TouchMirror: %v", m.Repo, err)
416+
}
414417
return false
415418
}
416419

0 commit comments

Comments
 (0)