mcriley821 / PyNotify

A Python asyncio interface to the Linux inotify API
The Unlicense
37 stars 2 forks source link

Watch a directory recursively #2

Open roma-glushko opened 1 year ago

roma-glushko commented 1 year ago

Hey folks 👋

Is it possible to watch the directory recursively? So when I do watch("/home/roma/"), I receive events from:

I assume that this is a common case for inotify usage and would be great to have in pynotify.

Thank you in advance!

mcriley821 commented 1 year ago

Hello 👋

First off, thank you for showing interest in this project!

My initial motivation for creating this project was to make it easier to create an encrypted mirror of a few directories, so recursive usage was in mind.

During the design of PyNotify, though, I decided against including recursive capabilities. This was mostly because it should be relatively easy to implement on the consumer side, but also because it breaks the current level of abstraction. The library is currently an one layer above inotify (sending to handlers), whereas recursiveness implies another layer above (handling events).

I'm not against implementing recursiveness, I'm just providing the reasoning behind it not being implemented already. Perhaps an extra module to implement common tasks like this could create the separation of concerns desired?