diff --git a/asink/watcher.go b/asink/watcher.go index ddaf843..ab6cbdd 100644 --- a/asink/watcher.go +++ b/asink/watcher.go @@ -43,6 +43,11 @@ func StartWatching(watchDir string, fileUpdates chan *asink.Event) { //if a directory was created, begin recursively watching all its subdirectories if fi, err := os.Stat(ev.Name); err == nil && fi.IsDir() { if ev.IsCreate() { + //Note: even though filepath.Walk will visit root, we must watch root first so we catch files/directories created after the walk begins but before this directory begins being watched + err = watcher.Watch(ev.Name) + if err != nil { + panic("Failed to watch " + ev.Name) + } filepath.Walk(ev.Name, watchDirFn) //TODO do a scan of this directory so we ensure any file events we missed before starting to watch this directory are caught }