From 599adde1bc3670279d371fd9f2620c2829286bf6 Mon Sep 17 00:00:00 2001 From: Jonas Bröms <9416498+cez81@users.noreply.github.com> Date: Fri, 9 Nov 2018 00:58:02 +0100 Subject: Add option to disable automatic mirror syncing. (#5242) Setting the interval to 0 will disable to automatic syncing. --- models/repo_mirror.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'models/repo_mirror.go') diff --git a/models/repo_mirror.go b/models/repo_mirror.go index 447d055307..9f8c9bee65 100644 --- a/models/repo_mirror.go +++ b/models/repo_mirror.go @@ -63,7 +63,11 @@ func (m *Mirror) AfterLoad(session *xorm.Session) { // ScheduleNextUpdate calculates and sets next update time. func (m *Mirror) ScheduleNextUpdate() { - m.NextUpdateUnix = util.TimeStampNow().AddDuration(m.Interval) + if m.Interval != 0 { + m.NextUpdateUnix = util.TimeStampNow().AddDuration(m.Interval) + } else { + m.NextUpdateUnix = 0 + } } func remoteAddress(repoPath string) (string, error) { @@ -302,6 +306,7 @@ func MirrorUpdate() { if err := x. Where("next_update_unix<=?", time.Now().Unix()). + And("next_update_unix!=0"). Iterate(new(Mirror), func(idx int, bean interface{}) error { m := bean.(*Mirror) if m.Repo == nil { -- cgit v1.2.3