summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2009-10-29 20:28:25 +0100
committerSebastien Martini <seb@dbzteam.org>2009-10-29 20:28:25 +0100
commitf2dac0bc86c6ddccef0dbf974847429471c5f283 (patch)
treefc3462d5165c1c54c9320d242eb3d364dba8cf31
parenteba40b6fde274ee44ad98ad0c5b438def813181a (diff)
downloadpyinotify-f2dac0bc86c6ddccef0dbf974847429471c5f283.tar.gz
Automatically watch a non watched tree moved to a watched directory
with flag auto_add activated (contributed by John Feuerstein john@feurix.com).
-rwxr-xr-xpyinotify.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/pyinotify.py b/pyinotify.py
index 3a662e7..fb26f20 100755
--- a/pyinotify.py
+++ b/pyinotify.py
@@ -711,6 +711,12 @@ class _SysProcessEvent(_ProcessEvent):
# to provide as additional information to the IN_MOVED_TO event
# the original pathname of the moved file/directory.
to_append['src_pathname'] = mv_[0]
+ elif raw_event.mask & IN_ISDIR and watch_.auto_add:
+ # We got a diretory that's "moved in" from an unknown source and
+ # auto_add is enabled. Manually add watches to the inner subtrees.
+ self._watch_manager.add_watch(dst_path, watch_.mask,
+ proc_fun=watch_.proc_fun,
+ rec=True, auto_add=True)
return self.process_default(raw_event, to_append)
def process_IN_MOVE_SELF(self, raw_event):
@@ -731,7 +737,7 @@ class _SysProcessEvent(_ProcessEvent):
if mv_:
dest_path = mv_[0]
watch_.path = dest_path
- # The next loop renames all watches.
+ # The next loop renames all watches with src_path as base path.
# It seems that IN_MOVE_SELF does not provide IN_ISDIR information
# therefore the next loop is iterated even if raw_event is a file.
for w in self._watch_manager.watches.itervalues():