lib/scanner, lib/model: Improve error handling when scanning (#6736)
This commit is contained in:
parent
f619a7f4cc
commit
a47546a1f1
|
@ -394,8 +394,12 @@ func (f *folder) scanSubdirs(subDirs []string) error {
|
||||||
|
|
||||||
f.setState(FolderScanning)
|
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()
|
mtimefs := f.fset.MtimeFS()
|
||||||
fchan := scanner.Walk(f.ctx, scanner.Config{
|
fchan := scanner.Walk(scanCtx, scanner.Config{
|
||||||
Folder: f.ID,
|
Folder: f.ID,
|
||||||
Subs: subDirs,
|
Subs: subDirs,
|
||||||
Matcher: f.ignores,
|
Matcher: f.ignores,
|
||||||
|
@ -885,6 +889,7 @@ func (f *folder) String() string {
|
||||||
|
|
||||||
func (f *folder) newScanError(path string, err error) {
|
func (f *folder) newScanError(path string, err error) {
|
||||||
f.scanErrorsMut.Lock()
|
f.scanErrorsMut.Lock()
|
||||||
|
l.Infof("Scanner (folder %s, item %q): %v", f.Description(), path, err)
|
||||||
f.scanErrors = append(f.scanErrors, FileError{
|
f.scanErrors = append(f.scanErrors, FileError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
Path: path,
|
Path: path,
|
||||||
|
|
|
@ -531,7 +531,6 @@ func (w *walker) handleError(ctx context.Context, context, path string, err erro
|
||||||
if fs.IsNotExist(err) {
|
if fs.IsNotExist(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.Infof("Scanner (folder %s, item %q): %s: %v", w.Folder, path, context, err)
|
|
||||||
select {
|
select {
|
||||||
case finishedChan <- ScanResult{
|
case finishedChan <- ScanResult{
|
||||||
Err: fmt.Errorf("%s: %w", context, err),
|
Err: fmt.Errorf("%s: %w", context, err),
|
||||||
|
|
Loading…
Reference in New Issue