Skip to content

Commit

Permalink
skip ignored files before callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie authored and progrium committed Apr 29, 2020
1 parent 88c0f93 commit 0a75e80
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,6 @@ func (w *Watcher) listRecursive(name string) (map[string]os.FileInfo, error) {
return err
}

for _, f := range w.ffh {
err := f(info, path)
if err == ErrSkip {
return nil
}
if err != nil {
return err
}
}

// If path is ignored and it's a directory, skip the directory. If it's
// ignored and it's a single file, skip the file.
_, ignored := w.ignored[path]
Expand All @@ -336,6 +326,17 @@ func (w *Watcher) listRecursive(name string) (map[string]os.FileInfo, error) {
}
return nil
}

for _, f := range w.ffh {
err := f(info, path)
if err == ErrSkip {
return nil
}
if err != nil {
return err
}
}

// Add the path and it's info to the file list.
fileList[path] = info
return nil
Expand Down

0 comments on commit 0a75e80

Please sign in to comment.