Skip to content

Commit 6c5a13c

Browse files
author
xiaoyang-chen
committed
feat: only radovskyb-watcher update, merge radovskyb/watcher#100 for skip ignored files before callbacks
1 parent d843c53 commit 6c5a13c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

radovskyb-watcher/watcher.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,6 @@ func (w *Watcher) listRecursive(name string) (fileList map[string]os.FileInfo, e
315315
err = inErr
316316
return
317317
}
318-
for _, f := range w.ffh {
319-
switch err = f(info, path); err {
320-
case nil:
321-
case ErrSkip:
322-
err = nil
323-
return
324-
default:
325-
return
326-
}
327-
}
328318
// If path is ignored and it's a directory, skip the directory. If it's
329319
// ignored and it's a single file, skip the file.
330320
var isHidden bool
@@ -337,6 +327,17 @@ func (w *Watcher) listRecursive(name string) (fileList map[string]os.FileInfo, e
337327
}
338328
return
339329
}
330+
// callbacks after skip ignored files
331+
for _, f := range w.ffh {
332+
switch err = f(info, path); err {
333+
case nil:
334+
case ErrSkip:
335+
err = nil
336+
return
337+
default:
338+
return
339+
}
340+
}
340341
// Add the path and it's info to the file list.
341342
// notice: if a dir skipped by w.ffh but the files below it do not, the files will add into this fileLists
342343
fileList[path] = info

0 commit comments

Comments
 (0)