From 9b2a73f9abb34e6bd207570a14121fb20a43735a Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Wed, 10 Apr 2019 16:22:23 +0200 Subject: [PATCH] lib/model: Pause pull for at least as long as failed pull took (fixes #5641) (#5643) --- lib/model/folder.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/model/folder.go b/lib/model/folder.go index 0a155041c..087286127 100644 --- a/lib/model/folder.go +++ b/lib/model/folder.go @@ -132,6 +132,23 @@ func (f *folder) Serve() { initialCompleted := f.initialScanFinished + pull := func() { + startTime := time.Now() + if f.puller.pull() { + // We're good. Don't schedule another pull and reset + // the pause interval. + pause = f.basePause() + return + } + // Pulling failed, try again later. + delay := pause + time.Since(startTime) + l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), delay) + pullFailTimer.Reset(delay) + if pause < 60*f.basePause() { + pause *= 2 + } + } + for { select { case <-f.ctx.Done(): @@ -143,27 +160,10 @@ func (f *folder) Serve() { case <-pullFailTimer.C: default: } - - if !f.puller.pull() { - // Pulling failed, try again later. - pullFailTimer.Reset(pause) - } + pull() case <-pullFailTimer.C: - if f.puller.pull() { - // We're good. Don't schedule another fail pull and reset - // the pause interval. - pause = f.basePause() - continue - } - - // Pulling failed, try again later. - l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), pause) - pullFailTimer.Reset(pause) - // Back off from retrying to pull with an upper limit. - if pause < 60*f.basePause() { - pause *= 2 - } + pull() case <-initialCompleted: // Initial scan has completed, we should do a pull