From c120c3a403b652a5d2ec0ed0d483cae40e74340a Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 13 Feb 2018 11:02:07 +0100 Subject: [PATCH] lib/scanner: Error handling in walk function (fixes #4753) (#4754) --- lib/scanner/walk.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index 5112f1e87..81dce7f59 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -255,11 +255,14 @@ func (w *walker) createFSWalkFn(ctx context.Context, fsChan chan<- fsWalkResult) skip = fs.SkipDir } - if path == "." { - if err != nil { - fsWalkError(ctx, fsChan, path, err) - return skip + if err != nil { + if sendErr := fsWalkError(ctx, fsChan, path, err); sendErr != nil { + return sendErr } + return skip + } + + if path == "." { return nil } @@ -282,13 +285,6 @@ func (w *walker) createFSWalkFn(ctx context.Context, fsChan chan<- fsWalkResult) return skip } - if err != nil { - if sendErr := fsWalkError(ctx, fsChan, path, err); sendErr != nil { - return sendErr - } - return skip - } - if !utf8.ValidString(path) { if err := fsWalkError(ctx, fsChan, path, errors.New("path isn't a valid utf8 string")); err != nil { return err