hawk icon indicating copy to clipboard operation
hawk copied to clipboard

If file does not exist when watcher is started, does not watch

Open dryewo opened this issue 8 years ago • 4 comments

Hello Will,

I picked this library among others because it supports watching single files rather than directories (unlike other libraries like clojure-watch or juxt/dirwatch). However, I ran into an issue:

If I start a watcher on a single file that does not exist, it does not notice when the file is created. But if I start it when the file exists, it notices deletion and creation. Is this intended behavior?

Thanks in advance.

dryewo avatar Jan 19 '18 22:01 dryewo

Also, it crashes on Linux, for example:

(hawk/watch! [{:paths   ["/foobar"]
               :handler (constantly nil)}])

When /foobar does not exist, it crashes on Linux, but passes on OS X.

java.nio.file.NoSuchFileException: /foobar
 at sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
    sun.nio.fs.UnixException.asIOException (UnixException.java:111)
    sun.nio.fs.LinuxWatchService$Poller.implRegister (LinuxWatchService.java:246)
    sun.nio.fs.AbstractPoller.processRequests (AbstractPoller.java:260)
    sun.nio.fs.LinuxWatchService$Poller.run (LinuxWatchService.java:329)
    java.lang.Thread.run (Thread.java:748)

dryewo avatar Jan 20 '18 12:01 dryewo

Hey there! Thanks for using the library!

This does not seem like the intended behavior, I'll take a look.

wkf avatar Jan 22 '18 14:01 wkf

I don't mean to bother, but is this being worked on at all?

NoahTheDuke avatar Oct 04 '18 02:10 NoahTheDuke

BTW, I made a simple library to work around this: https://github.com/dryewo/mem-files

dryewo avatar Oct 04 '18 08:10 dryewo