-
-
Notifications
You must be signed in to change notification settings - Fork 966
Cannot remove watch for deleted file #40
Copy link
Copy link
Closed
Description
Once a file is deleted, you cannot clean up watches for it. For instance, with fsnotify:
func (w *Watcher) Remove(name string) error {
name = filepath.Clean(name)
w.mu.Lock()
defer w.mu.Unlock()
watch, ok := w.watches[name]
if !ok {
return fmt.Errorf("can't remove non-existent inotify watch for: %s", name)
}
success, errno := syscall.InotifyRmWatch(w.fd, watch.wd)
if success == -1 {
return os.NewSyscallError("inotify_rm_watch", errno)
}
delete(w.watches, name)
return nil
}The file is gone, so even though we find the watch in w.watches we return a syscall error and don't delete the entry from w.watches.
It seems that maybe we should delete from w.watches regardless, or at least if errno is EBADF. If this sounds good, I can make a PR (and try to figure out the appropriate change for other systems (at least darwin) as well.
Reactions are currently unavailable