rjeczalik / notify

File system event notification library on steroids.
MIT License
900 stars 128 forks source link

Recursive watcher for windows shared drive does not report events in subdirectories #202

Closed saumitravistaprint closed 3 years ago

saumitravistaprint commented 3 years ago

My code is a toy program for the recursive watcher.

func (watcher *RecursiveWatcher) StartWatching() error {
    if err := notify.Watch(watcher.directory + "/...", watcher.watchChannel, notify.All); err != nil {
        return err
    }
    watcher.ctx, watcher.cancel = context.WithCancel(context.Background())
    watcher.watch()
    return nil
}

func (watcher *RecursiveWatcher) watch() {
    go func() {
        for {
            select {
                case notifyEvent:= <-watcher.watchChannel:
                    log.Println("Got new event", notifyEvent.Event().String(), notifyEvent.Path(), notifyEvent.Sys())
                case <-watcher.ctx.Done():
                    log.Println("watch(): closing watcher")
                    return
            }
        }
    }()
}

The directory is a shared network folder e.g. "//COMPUTER/test_share/...", and is accessible by the program. I get events if they're made in the directory "test_share", but if there are any events in the subdirectories, I get no notifications.

saumitravistaprint commented 3 years ago

Apparently watching a directory lower than the root works, the root share doesn't.