summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-03-01 21:55:22 +0100
committerSebastien Martini <seb@dbzteam.org>2010-03-01 21:55:22 +0100
commitc3cb39c167234e651ef20b1647161a073c2b9454 (patch)
tree7d5a2643f9b850568d67b597932573dc50d884e5
parenta3fbdda201166260886f2644f4fe725e5a832fd5 (diff)
downloadpyinotify-c3cb39c167234e651ef20b1647161a073c2b9454.tar.gz
Fixed IN_MOVE_SELF renames of overlapping directories names
(contributed by Facundo Batista facundo@canonical.com).
-rwxr-xr-xpython2/pyinotify.py7
-rwxr-xr-xpython3/pyinotify.py7
2 files changed, 8 insertions, 6 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index 05dd2f8..ef2ee7e 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -681,16 +681,17 @@ class _SysProcessEvent(_ProcessEvent):
if mv_:
dest_path = mv_[0]
watch_.path = dest_path
+ # add the separator to the source path to avoid overlapping
+ # path issue when testing with startswith()
+ src_path += os.path.sep
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.values():
if w.path.startswith(src_path):
# Note that dest_path is a normalized path.
- w.path = os.path.join(dest_path,
- w.path[src_path_len + sep_len:])
+ w.path = os.path.join(dest_path, w.path[src_path_len:])
else:
log.error("The pathname '%s' of this watch %s has probably changed "
"and couldn't be updated, so it cannot be trusted "
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index 9a8cbbc..27fa0fb 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -645,16 +645,17 @@ class _SysProcessEvent(_ProcessEvent):
if mv_:
dest_path = mv_[0]
watch_.path = dest_path
+ # add the separator to the source path to avoid overlapping
+ # path issue when testing with startswith()
+ src_path += os.path.sep
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.values():
if w.path.startswith(src_path):
# Note that dest_path is a normalized path.
- w.path = os.path.join(dest_path,
- w.path[src_path_len + sep_len:])
+ w.path = os.path.join(dest_path, w.path[src_path_len:])
else:
log.error("The pathname '%s' of this watch %s has probably changed "
"and couldn't be updated, so it cannot be trusted "