lib/scanner, lib/model: Improve error handling when scanning (#6736)

This commit is contained in:
Simon Frei 2020-06-16 09:25:41 +02:00 committed by GitHub
parent f619a7f4cc
commit a47546a1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -394,8 +394,12 @@ func (f *folder) scanSubdirs(subDirs []string) error {
f.setState(FolderScanning)
// If we return early e.g. due to a folder health error, the scan needs
// to be cancelled.
scanCtx, scanCancel := context.WithCancel(f.ctx)
defer scanCancel()
mtimefs := f.fset.MtimeFS()
fchan := scanner.Walk(f.ctx, scanner.Config{
fchan := scanner.Walk(scanCtx, scanner.Config{
Folder: f.ID,
Subs: subDirs,
Matcher: f.ignores,
@ -885,6 +889,7 @@ func (f *folder) String() string {
func (f *folder) newScanError(path string, err error) {
f.scanErrorsMut.Lock()
l.Infof("Scanner (folder %s, item %q): %v", f.Description(), path, err)
f.scanErrors = append(f.scanErrors, FileError{
Err: err.Error(),
Path: path,

View File

@ -531,7 +531,6 @@ func (w *walker) handleError(ctx context.Context, context, path string, err erro
if fs.IsNotExist(err) {
return
}
l.Infof("Scanner (folder %s, item %q): %s: %v", w.Folder, path, context, err)
select {
case finishedChan <- ScanResult{
Err: fmt.Errorf("%s: %w", context, err),