howeyc/fsnotify

Is it possible to watch a single file?

mstum opened this issue · 1 comments

I want to use fsnotify as a Configuration-file hot reloader. The configuration file may be in a directory with many other files (e.g., /etc on Linux).

I don't know if the underlying operating systems support it, but is it possible to only watch a single file? (I'm right now filtering the ev.Name with string.HasSuffix which works for me, just wondering if the watcher itself can be simplified to keep load as low as possible)

Setting up the watcher with watcher.Watch("/etc/myconfig.conf") works, but also catches events on a file called myconfig.conf~ like the temp files greated by vim.

I saw saw the remarks on #37 and that also just explained an issue I'm troubleshooting - when I use vim - vim creates a temp file, deletes the original and renames the temp file and I was wondering why fsnotify wasn't firing after that. Now I know that I lose my watch when the watched file/folder is deleted :)