// WatchDir observes changes to the given directory
// and notifies on a channel when they occur.
WatchDir observes changes to the given directory
and notifies on a channel when they occur.
// WatchDir observes changes to the given directory // and notifies on a channel when they occur .
func WatchDir(dir string) (dirUpdated chan bool) {
	dirUpdated = make(chan bool)
	w := watcher.New()
	if err := w.AddRecursive(dir); err != nil {
		logrus.Warnln(err)
	}
	go func() {
		logrus.Infof("watching for changes to: %v", dir)
		for {
			select {
			case <-w.Event:
				dirUpdated <- true
				break
			case err := <-w.Error:
				logrus.Warnln(err)
			case <-w.Closed:
				return
			}
		}
	}()
	go func() {
		if err := w.Start(time.Millisecond * checkIntervalMs); err != nil {
			logrus.Warnln(err)
		}
	}()
	return dirUpdated
}
func WatchDir ( dir string ) ( dirUpdated chan bool ) { dirUpdated = make ( chan bool ) w := watcher . New ( ) if err := w . AddRecursive ( dir ) ; err != nil { logrus . Warnln ( err ) } go func ( ) { logrus . Infof ( " " , dir ) for { select { case <- w . Event : dirUpdated <- true break case err := <- w . Error : logrus . Warnln ( err ) case <- w . Closed : return } } } ( ) go func ( ) { if err := w . Start ( time . Millisecond * checkIntervalMs ) ; err != nil { logrus . Warnln ( err ) } } ( ) return dirUpdated }
WatchDir observes changes to the given directory
and notifies on a channel when they occur.
WatchDir observes changes to the given directory and notifies on a channel when they occur .