diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index 44423ca7..5f76a848 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -215,18 +215,14 @@ func (w *walker) walkAndHashFiles(ctx context.Context, toHashChan chan<- protoco skip = fs.SkipDir } - if err != nil { - w.handleError(ctx, "scan", path, err, finishedChan) + if !utf8.ValidString(path) { + w.handleError(ctx, "scan", path, errUTF8Invalid, finishedChan) return skip } - if path == "." { - return nil - } - if fs.IsTemporary(path) { - l.Debugln("temporary:", path) - if info.IsRegular() && info.ModTime().Add(w.TempLifetime).Before(now) { + l.Debugln("temporary:", path, "err:", err) + if err == nil && info.IsRegular() && info.ModTime().Add(w.TempLifetime).Before(now) { w.Filesystem.Remove(path) l.Debugln("removing temporary:", path, info.ModTime()) } @@ -238,15 +234,10 @@ func (w *walker) walkAndHashFiles(ctx context.Context, toHashChan chan<- protoco return skip } - if !utf8.ValidString(path) { - w.handleError(ctx, "scan", path, errUTF8Invalid, finishedChan) - return skip - } - if w.Matcher.Match(path).IsIgnored() { l.Debugln("ignored (patterns):", path) // Only descend if matcher says so and the current file is not a symlink. - if w.Matcher.SkipIgnoredDirs() || info.IsSymlink() { + if err != nil || w.Matcher.SkipIgnoredDirs() || info.IsSymlink() { return skip } // If the parent wasn't ignored already, set this path as the "highest" ignored parent @@ -256,6 +247,15 @@ func (w *walker) walkAndHashFiles(ctx context.Context, toHashChan chan<- protoco return nil } + if err != nil { + w.handleError(ctx, "scan", path, err, finishedChan) + return skip + } + + if path == "." { + return nil + } + if ignoredParent == "" { // parent isn't ignored, nothing special return w.handleItem(ctx, path, toHashChan, finishedChan, skip) diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go index da1a2989..74725a51 100644 --- a/lib/scanner/walk_test.go +++ b/lib/scanner/walk_test.go @@ -252,6 +252,7 @@ func TestNormalization(t *testing.T) { func TestIssue1507(t *testing.T) { w := &walker{} + w.Matcher = ignore.New(w.Filesystem) h := make(chan protocol.FileInfo, 100) f := make(chan ScanResult, 100) fn := w.walkAndHashFiles(context.TODO(), h, f)