seb-m / pyinotify

Monitoring filesystems events with inotify on Linux.
http://github.com/seb-m/pyinotify/wiki
MIT License
2.29k stars 379 forks source link

Following symlinks recursively #83

Open xarg opened 10 years ago

xarg commented 10 years ago

It looks like pynotify doesn't follow symlink directories explicitly. I looked for an explanation, but couldn't find any. Is there a reason for not following symlinks?

For example this doesn't follow symlinks in the /tmp/ dir: watch_manager.add_watch('/tmp/', some_mask, rec=True)

seb-m commented 10 years ago

Indeed it doesn't follow symlinks recursively. If I recall correctly I didn't implement recursion on symlinks because it opened the door to other problems for instance you have to detect you haven't already iterated a directory otherwise you could be stuck in an infinite loop. Maybe I forget others problems too, but it is certainly possible to do it I think but it was more work.

xarg commented 10 years ago

@seb-m I see. Detecting an infinite loop should be possible to do. An error could be thrown in that case before setting up the listeners.

But what event is thrown when you modify a file in /tmp/original/ and there is 1 symlink pointing to that dir. Having in mind that both the original dir and the symlink are watched what's the behaviour here?

Throwing 2 events (original path + symlinked path) or only the original?

Example:

/tmp/watched/original
/tmp/watched/sym -> /tmp/watched/original

I perform:

touch /tmp/watched/original/x.

What happens?

seb-m commented 10 years ago

You have to test it by yourself to be sure but I think only the event on the original path is reported.