Hi, I found jnotify to be a very good piece of software, and it was exactly what we were looking for. However, I noticed one problem:
- suppose you watch folder /tmp/a
- you do not watch folder /tmp/b
- you (or another program) moves /tmp/a/test to /tmp/b
-> jnotify will not notify you (tested on Linux)!
This is because it will wait for the second event of a "rename/move" action (IN_MOVE_TO), which will never come to my program because it cannot watch every folder.
This is not a bug, but a logical issue, although it could become a memory hog when many (many) files are moved away (out of watch scope), because all the "old" filenames are being kept in memory (in case they come back one day).
For my purposes, and I think others could benefit as well, the solution I saw is to (optionally) notify the move event as a delete event and then another create event. Thus, if the file is moved away (to a directory we don't watch), we get at least the "delete" event, or, if a file is moved in, we will not get a "rename" event with (null) source file name, but a "create" event.
This is also the only way I'm aware of to get _both_ directories when files are moved from one watched directory to another watched directory.
I introduced a new flag TREAT_MOVE_AS_DELETE_CREATE and it should work on Windows and Linux, but I have only tested Linux due to lack of availbility of Windows machine.
patch for "treat move as delete+create"
View and moderate all "patches Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Patches"
Patch works good for me. Had to manually fix it to latest version, but wasn't hard. The only thing that is strange is that one needs to be watching for rename. It's not so intuitive.