refactor: only update sync status columns when syncing push mirror (#39517)

`UpdatePushMirror` used `AllCols()`, so a sync could overwrite columns
changed concurrently (e.g. `interval`) with stale values. It now updates
only `last_update` and `last_error`, and is renamed to
`UpdatePushMirrorSyncStatus` to match.

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 5) <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-10-02 19:28:51 +00:00
1 parent cf89ecd887
commit 6dad3ad43d
3 files changed
+8 -6

No files matched your search

+4 -4
View File
@@ -78,13 +78,13 @@ func (m *PushMirror) GetRemoteName() string {
return m.RemoteName
}
// UpdatePushMirror updates the push-mirror
func UpdatePushMirror(ctx context.Context, m *PushMirror) error {
_, err := db.GetEngine(ctx).ID(m.ID).AllCols().Update(m)
// UpdatePushMirrorSyncStatus updates the sync status (last update time and last error) of the push-mirror
func UpdatePushMirrorSyncStatus(ctx context.Context, m *PushMirror) error {
_, err := db.GetEngine(ctx).ID(m.ID).Cols("last_update", "last_error").Update(m)
return err
}
// UpdatePushMirrorInterval updates the push-mirror
// UpdatePushMirrorInterval updates the sync interval of the push-mirror
func UpdatePushMirrorInterval(ctx context.Context, m *PushMirror) error {
_, err := db.GetEngine(ctx).ID(m.ID).Cols("interval").Update(m)
return err