Lookup Watch ID Given a Path?
Closed this issue · 2 comments
Any intention to add a 4th method: get_wd(path)
? This would be very useful for me to have implemented here (rather than around INotify
in my code), and am willing to add this and PR if it is alright.
Hej Chris,
I actually had get_wd(path)
implemented in a development version that was never committed, but decided to remove it in the end, because - at least in my implementation - deriving wd
from path
was quite expensive, because in general for a path, which consists of n parts, the whole __info
map has to be searched n times.
The are probably some optimization-possibilities for specials cases, but I didn't implement them, because I thought that even in the best case the __info
map has to be searched one time. In general the fastest general solution I could think of would be to store wd
in a path
:wd
map right after the add_watch_recursive()
call, if you know that you need wd
later. The worst case of this implementation would be still as fast as the best case of my get_wd(path)
implementation, so I decdied to drop get_wd(path)
again.
Apart from the speed considerations I also didn't like the idea of having a get_wd(path)
function, because I'd like to follow the implement-only-the-necessary-philosophy of the underlying inotify_simple package. In fact I'd be happy, if I could drop get_path(wd)
as well ;)
However, I'd like to know your implementation and the reasons why you need it. So please create a PR, if you have the code done already. Maybe my previous conclusions were wrong and it makes sense to include get_wd(path)
into the package anyway.
Hej Chris,
any news on this issue? I'm still curious about your implementation. If not, I would close this issue by the end of this week.