diff options
author | zeripath <art27@cantab.net> | 2022-03-27 15:40:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-27 15:40:17 +0100 |
commit | d2ca021df0eccd6103b9f0f4a0b942dc95bd18b8 (patch) | |
tree | 74ace2a113db00319a420cba2b2ce4ce456c0ced /models | |
parent | c29fbc6d2316b8b42b37c3b379eb2297f7a93aeb (diff) | |
download | gitea-d2ca021df0eccd6103b9f0f4a0b942dc95bd18b8.tar.gz gitea-d2ca021df0eccd6103b9f0f4a0b942dc95bd18b8.zip |
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>
Diffstat (limited to 'models')
-rw-r--r-- | models/repo/mirror.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/repo/mirror.go b/models/repo/mirror.go index 8494331ff7..df4e320752 100644 --- a/models/repo/mirror.go +++ b/models/repo/mirror.go @@ -6,6 +6,7 @@ package repo import ( + "context" "errors" "fmt" "time" @@ -113,6 +114,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}) |