diff --git a/models/repo/mirror.go b/models/repo/mirror.go index bdb449af3a76..e329dc8693cd 100644 --- a/models/repo/mirror.go +++ b/models/repo/mirror.go @@ -6,6 +6,7 @@ package repo import ( + "context" "errors" "fmt" "time" @@ -115,6 +116,13 @@ func UpdateMirror(m *Mirror) error { return updateMirror(db.GetEngine(db.DefaultContext), m) } +// TouchMirror updates the mirror updatedUnix +func TouchMirror(ctx context.Context, m *Mirror) error { + m.UpdatedUnix = timeutil.TimeStampNow() + _, err := db.GetEngine(ctx).ID(m.ID).Cols("updated_unix").Update(m) + return err +} + // DeleteMirrorByRepoID deletes a mirror by repoID func DeleteMirrorByRepoID(repoID int64) error { _, err := db.GetEngine(db.DefaultContext).Delete(&Mirror{RepoID: repoID}) diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go index 697e2545249c..000b076fb36a 100644 --- a/services/mirror/mirror_pull.go +++ b/services/mirror/mirror_pull.go @@ -387,6 +387,9 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool { log.Trace("SyncMirrors [repo: %-v]: Running Sync", m.Repo) results, ok := runSync(ctx, m) if !ok { + if err = repo_model.TouchMirror(ctx, m); err != nil { + log.Error("SyncMirrors [repo: %-v]: failed to TouchMirror: %v", m.Repo, err) + } return false }