Ejemplo n.º 1
0
func handleChange(event fsnotify.Event,
	db *SymbolsDB,
	watcher *fsnotify.Watcher,
	files chan string) {

	visitorDir := func(path string) {
		// add watcher to directory
		watcher.Add(path)
	}
	visitorC := func(path string) {
		// add watcher
		watcher.Add(path)
		// put file in channel
		files <- path
	}

	switch {
	case event.Op&(fsnotify.Write|fsnotify.Create|fsnotify.Chmod) != 0:
		traversePath(event.Name, visitorDir, visitorC)
	case event.Op&(fsnotify.Remove|fsnotify.Rename) != 0:
		watcher.Remove(event.Name)
		tx := db.BeginTx()
		tx.RemoveFileReferences(filepath.Clean(event.Name))
		tx.Close()
	}
}
Ejemplo n.º 2
0
func (s *SpecInfoGatherer) removeWatcherOn(watcher *fsnotify.Watcher, path string) {
	logger.APILog.Info("Removing watcher on : %s", path)
	watcher.Remove(path)
}
Ejemplo n.º 3
0
func (specInfoGatherer *specInfoGatherer) removeWatcherOn(watcher *fsnotify.Watcher, path string) {
	logger.ApiLog.Error("Removing watcher on : %s", path)
	watcher.Remove(path)
}