From eb4510b3fe53fc6e2c94015d98c3208540cf3107 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 24 Jun 2018 20:49:28 -0300 Subject: [PATCH] Fix watcher scan skipping a whole directory on ignored files --- watcher.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/watcher.go b/watcher.go index 6890c54..b1d4d78 100644 --- a/watcher.go +++ b/watcher.go @@ -88,12 +88,12 @@ func (w *Watcher) scanChange(watchPath string) (string, error) { err := filepath.Walk(watchPath, func(path string, info os.FileInfo, err error) error { // always ignore hidden files and directories - if filepath.Base(path)[0] == '.' { - return nil + if dir := filepath.Base(path); dir[0] == '.' && dir != "." { + return skipFile(info) } if _, ignored := w.IgnoreItems[path]; ignored { - return filepath.SkipDir + return skipFile(info) } ext := filepath.Ext(path) @@ -175,3 +175,10 @@ func removeOverlappedPaths(mapPaths map[string]bool) { } } } + +func skipFile(info os.FileInfo) error { + if info.IsDir() { + return filepath.SkipDir + } + return nil +}