-
Notifications
You must be signed in to change notification settings - Fork 14
How to handle "folders created/deleted after registration"? #44
Comments
Yes, the was the idea (register/unregister inside the callbacks). It shouldn't cause problems when concurrency > 1 because the concurrency is for the number of actors doing the callbacks, which is different from the MonitorActor that holds the registry of path+event-type -> callback functions :) |
Thanks! |
I think this worth reconsidering. Even Oracle's canonical example here: https://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java Btw, I am the author of another implementation (https://github.com/pathikrit/better-files#file-watchers) of this based purely on Java threads: |
@pathikrit thanks for the note; I've starred your repo since a while ago :) I can't remember why I had left that for end-users to handle, but theoretically it looks simple enough to implement: // if directory is created, and watching recursively, then
// register it and its sub-directories
if (recursive && (kind == ENTRY_CREATE)) {
try {
if (Files.isDirectory(child, NOFOLLOW_LINKS)) {
registerAll(child);
}
} catch (IOException x) {
// ignore to keep sample readbale
}
} Just leaving a note on a possible implementation: I think in this lib, this can be handled by having the watch path message (watchMsg1) have a |
In README:
Do you mean developers should unregister and register again inside the callback functions? Is there problem when
concurrency
> 1?The text was updated successfully, but these errors were encountered: