Unless the action is atomic, there is still no guarantee that the path will exist between the time you check and when you set the monitor.

Sent from Yahoo Mail on Android

On Sat, Mar 17, 2018 at 12:28 PM, H. William Welliver III
<william@welliver.org> wrote:
I’ve noticed that when using Filesystem.Monitor on a system with inotify there is the possibility of monitors being created on paths that don’t exist.

Specifically, if a directory is created and deleted in very rapid succession, the inotify events are processed after the directory is already gone. The resulting Monitors hang around forever (with their associated polls). It doesn’t appear that any events get triggered for this situation, though I can’t be absolutely sure because I’m not watching for directory changes. My concern is that these phantom monitors can build up over time.

Does it make sense to check for the existence of something before monitoring it? I didn’t want to assume that was desirable because I suppose it’s possible someone might want to watch with the expectation that it will exist later… (maybe?)

Bill