[Gambas-user] Watch inotify directories recursively

Tobias Boege taboege at gmail.com
Thu Jun 28 17:44:26 CEST 2018


On Thu, 28 Jun 2018, Mayost Sharon wrote:
> Hello
> 
>  Is there a possibility of directories recursively
> 
> I see API documentation
> -r|--recursive	Watch directories recursively.
> 

Which documentation is that? Certainly not gb.inotify or the inotify
manpage. To watch a directory recursively, you must create new watches
for all its contents. And then you have to react to new files and
directories being created inside the hierarchy, by adding further
watches.

Also note that notification is asynchronous and the kernel does not
make any promises to notify you "quickly enough". It is entirely
possible that the following happens:

  1. you want to watch directory x/ recursively
  2. user creates directory x/y
  3. user creates file x/y/z
  4. user deletes file x/y/z
  5. user deletes directory x/y
  6. kernel decides to notify you of the event in step 2

When you handle the event produced in step 6, you will get a
Watch.Name which actually doesn't exist anymore (or might have
been re-created in the meantime!). You will also not have a
chance to see the creation of x/y/z because its containing
directory was already deleted before you were able to install
a watch for it.

Everyone using gb.inotify should read the "Limitations and caveats"
section of the manpage. (I'll add that note to the documentation
in a minute.)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list