lib/model, lib/config: Refactor folder health/error handling (fixes #4445, fixes #4451)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4455
LGTM: AudriusButkevicius, calmh
This commit is contained in:
Simon Frei
2017-10-24 07:58:55 +00:00
committed by Jakob Borg
parent a9c221189b
commit dc42db444b
9 changed files with 207 additions and 218 deletions

View File

@@ -165,7 +165,7 @@ func (f *sendReceiveFolder) Serve() {
var prevIgnoreHash string
if f.FSWatcherEnabled {
f.startWatcher()
f.startWatch()
}
for {
@@ -178,12 +178,6 @@ func (f *sendReceiveFolder) Serve() {
f.pullTimer.Reset(0)
l.Debugln(f, "remote index updated, rescheduling pull")
case <-f.ignoresUpdated:
if f.FSWatcherEnabled {
f.restartWatcher()
}
f.IndexUpdated()
case <-f.pullTimer.C:
select {
case <-f.initialScanFinished:
@@ -214,8 +208,8 @@ func (f *sendReceiveFolder) Serve() {
continue
}
if err := f.model.CheckFolderHealth(f.folderID); err != nil {
l.Infoln("Skipping pull of", f.Description(), "due to folder error:", err)
if err := f.CheckHealth(); err != nil {
l.Debugln("Skipping pull of", f.Description(), "due to folder error:", err)
f.pullTimer.Reset(f.sleep)
continue
}
@@ -292,6 +286,9 @@ func (f *sendReceiveFolder) Serve() {
case fsEvents := <-f.watchChan:
l.Debugln(f, "filesystem notification rescan")
f.scanSubdirs(fsEvents)
case <-f.restartWatchChan:
f.restartWatch()
}
}
}
@@ -1696,6 +1693,11 @@ func (f *sendReceiveFolder) currentErrors() []fileError {
return errors
}
func (f *sendReceiveFolder) IgnoresUpdated() {
f.folder.IgnoresUpdated()
f.IndexUpdated()
}
// A []fileError is sent as part of an event and will be JSON serialized.
type fileError struct {
Path string `json:"path"`