lib/model: Reset pull errors when succeeding (fix #5450) (#5451)

This commit is contained in:
Simon Frei 2019-01-14 08:30:52 +01:00 committed by Jakob Borg
parent 801e9b57eb
commit 51f65bd23a
1 changed files with 19 additions and 26 deletions

View File

@ -187,44 +187,37 @@ func (f *sendReceiveFolder) pull() bool {
f.setState(FolderIdle) f.setState(FolderIdle)
}() }()
var changed int for tries := 0; tries < maxPullerIterations; tries++ {
tries := 0
for {
tries++
changed = f.pullerIteration(ignores, folderFiles, scanChan)
select { select {
case <-f.ctx.Done(): case <-f.ctx.Done():
return false return false
default: default:
} }
l.Debugln(f, "changed", changed) changed := f.pullerIteration(ignores, folderFiles, scanChan)
l.Debugln(f, "changed", changed, "on try", tries)
if changed == 0 { if changed == 0 {
// No files were changed by the puller, so we are in // No files were changed by the puller, so we are in
// sync. // sync. Any errors were just transitional.
break f.clearPullErrors()
} return true
if tries == maxPullerIterations {
// We've tried a bunch of times to get in sync, but
// we're not making it. Probably there are write
// errors preventing us. Flag this with a warning and
// wait a bit longer before retrying.
if errors := f.Errors(); len(errors) > 0 {
events.Default.Log(events.FolderErrors, map[string]interface{}{
"folder": f.folderID,
"errors": errors,
})
}
break
} }
} }
return changed == 0 // We've tried a bunch of times to get in sync, but
// we're not making it. Probably there are write
// errors preventing us. Flag this with a warning and
// wait a bit longer before retrying.
if errors := f.Errors(); len(errors) > 0 {
events.Default.Log(events.FolderErrors, map[string]interface{}{
"folder": f.folderID,
"errors": errors,
})
}
return false
} }
// pullerIteration runs a single puller iteration for the given folder and // pullerIteration runs a single puller iteration for the given folder and