From f3f89a6266186433b4869e603153396829ce6671 Mon Sep 17 00:00:00 2001 From: Sebastien Martini Date: Sun, 11 Mar 2012 21:41:04 +0100 Subject: auto_add=True automatically implies oring IN_CREATE with the provided mask value. Misbehavior reported by Maxime Augier https://github.com/maugier. --- python2/pyinotify.py | 9 +++++++-- python3/pyinotify.py | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/python2/pyinotify.py b/python2/pyinotify.py index 9dac7c7..74d56db 100755 --- a/python2/pyinotify.py +++ b/python2/pyinotify.py @@ -1761,6 +1761,8 @@ class WatchManager: watch manager dictionary. Return the wd value. """ path = self.__format_path(path) + if auto_add and not mask & IN_CREATE: + mask |= IN_CREATE wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask) if wd < 0: return wd @@ -1805,6 +1807,8 @@ class WatchManager: @type rec: bool @param auto_add: Automatically add watches on newly created directories in watched parent |path| directory. + If |auto_add| is True, IN_CREATE is ored with |mask| + when the watch is added. @type auto_add: bool @param do_glob: Do globbing on pathname (see standard globbing module for more informations). @@ -1914,8 +1918,9 @@ class WatchManager: subdirectories contained into |wd| directory. @type rec: bool @param auto_add: Automatically adds watches on newly created - directories in the watch's path corresponding to - |wd|. + directories in the watch's path corresponding to |wd|. + If |auto_add| is True, IN_CREATE is ored with |mask| + when the watch is updated. @type auto_add: bool @param quiet: If False raises a WatchManagerError exception on error. See example not_quiet.py diff --git a/python3/pyinotify.py b/python3/pyinotify.py index 5194255..91cf532 100755 --- a/python3/pyinotify.py +++ b/python3/pyinotify.py @@ -1746,6 +1746,8 @@ class WatchManager: watch manager dictionary. Return the wd value. """ path = self.__format_path(path) + if auto_add and not mask & IN_CREATE: + mask |= IN_CREATE wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask) if wd < 0: return wd @@ -1788,6 +1790,8 @@ class WatchManager: @type rec: bool @param auto_add: Automatically add watches on newly created directories in watched parent |path| directory. + If |auto_add| is True, IN_CREATE is ored with |mask| + when the watch is added. @type auto_add: bool @param do_glob: Do globbing on pathname (see standard globbing module for more informations). @@ -1901,8 +1905,9 @@ class WatchManager: subdirectories contained into |wd| directory. @type rec: bool @param auto_add: Automatically adds watches on newly created - directories in the watch's path corresponding to - |wd|. + directories in the watch's path corresponding to |wd|. + If |auto_add| is True, IN_CREATE is ored with |mask| + when the watch is updated. @type auto_add: bool @param quiet: If False raises a WatchManagerError exception on error. See example not_quiet.py -- cgit v1.2.1