Correctly set and clear errors for missing folders (fixes #1937)

This commit is contained in:
Audrius Butkevicius
2015-06-13 19:10:11 +01:00
parent 7f56d5c23a
commit 1d856b4723
5 changed files with 36 additions and 6 deletions

View File

@@ -58,6 +58,7 @@ type service interface {
setState(state folderState)
setError(err error)
clearError()
getState() (folderState, time.Time, error)
}
@@ -1287,6 +1288,12 @@ nextSub:
fchan, err := w.Walk()
if err != nil {
// The error we get here is likely an OS level error, which might not be
// as readable as our health check errors. Check if we can get a health
// check error first, and use that if it's available.
if ferr := m.CheckFolderHealth(folder); ferr != nil {
err = ferr
}
runner.setError(err)
return err
}
@@ -1714,7 +1721,7 @@ func (m *Model) CheckFolderHealth(id string) error {
} else if oldErr != nil {
l.Infof("Folder %q error is cleared, restarting", folder.ID)
if runnerExists {
runner.setState(FolderIdle)
runner.clearError()
}
}