Add option to disable automatic mirror syncing. (#5242)
Setting the interval to 0 will disable to automatic syncing.
This commit is contained in:
parent
de8f98192b
commit
599adde1bc
3 changed files with 13 additions and 4 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue