summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2009-10-30 10:28:40 +0100
committerSebastien Martini <seb@dbzteam.org>2009-10-30 10:28:40 +0100
commit729bcf3910aedabef7396c8f43a3480a43a96afa (patch)
treeec4d4dddaeca8fab9014863132c247c31e76cfbf
parentf2dac0bc86c6ddccef0dbf974847429471c5f283 (diff)
downloadpyinotify-729bcf3910aedabef7396c8f43a3480a43a96afa.tar.gz
Fixed path renaming when a subtree is moved (contributed with
Linda Octalina linda_octa@yahoo.com and John Feuerstein john@feurix.com).
-rwxr-xr-xpyinotify.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyinotify.py b/pyinotify.py
index fb26f20..a9675cb 100755
--- a/pyinotify.py
+++ b/pyinotify.py
@@ -737,13 +737,16 @@ class _SysProcessEvent(_ProcessEvent):
if mv_:
dest_path = mv_[0]
watch_.path = dest_path
+ src_path_len = len(src_path)
+ sep_len = len(os.path.sep)
# 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():
if w.path.startswith(src_path):
# Note that dest_path is a normalized path.
- w.path = os.path.join(dest_path, w.path[len(dest_path):])
+ w.path = os.path.join(dest_path,
+ w.path[src_path_len + sep_len:])
else:
log.error("The pathname '%s' of this watch %s has probably changed "
"and couldn't be updated, so it cannot be trusted "