This library includes a Trapperkeeper service which provides an API for watching paths on the filesystem for changes and doing something when they change.
Add the following dependency to your project.clj file:
There is a bug in most released versions of OpenJDK on Linux that affect the behavior of this library.
Registering new watch paths while receiving incoming events can cause the event path to be misreported.
We encourage users to register all watch paths at start up prior to any expected events occuring. Currently only recursive file watching is supported, this means we will register any directory created by the user within an existing watch path. Thus creating a directory and then immediately creating a file or directory within the new directory will often trigger this issue.
See the above linked ticket and blog post for comprehensive info, as well as TK-387 for our discussion around this topic.
The service implementation in this repository is based on java.nio's
WatchService
.
The default implementation of that interface varies drastically in behavior
between certain platforms, especially Mac OSX and Linux. The Trapperkeeper
service protocol in this repository is consciously written in a
platform-agnostic way. When working on this code, it is often a good idea to
run the tests on multiple platforms as part of development - say, if you write
code on a Mac, run the tests on a Linux VM as well. This is can save you the
pain of finding out that things don't work as expected due to platform-specific
differences in the implementation of the JDK's WatchService
once your new
code gets into CI.
- Kevin Corcoran [email protected]
- Matthaus Owens [email protected]