Setting the interval to 0 will disable to automatic syncing.
// 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) {
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 {
default_branch = Default Branch
mirror_prune = Prune
mirror_prune_desc = Remove obsolete remote-tracking references
-mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's')
+mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync.
mirror_interval_invalid = The mirror interval is not valid.
mirror_address = Clone From URL
mirror_address_desc = Include any required authorization credentials in the URL.
}
interval, err := time.ParseDuration(form.Interval)
- if err != nil || interval < setting.Mirror.MinInterval {
+ if err != nil && (interval != 0 || interval < setting.Mirror.MinInterval) {
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
} else {
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
ctx.Repo.Mirror.Interval = interval
- ctx.Repo.Mirror.NextUpdateUnix = util.TimeStampNow().AddDuration(interval)
+ if interval != 0 {
+ ctx.Repo.Mirror.NextUpdateUnix = util.TimeStampNow().AddDuration(interval)
+ } else {
+ ctx.Repo.Mirror.NextUpdateUnix = 0
+ }
if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
return