Created
January 3, 2011 12:07
-
-
Save timbertson/763397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/watchdog/observers/inotify.py b/src/watchdog/observers/inotify.py | |
index 4ea8004..ac6136f 100644 | |
--- a/src/watchdog/observers/inotify.py | |
+++ b/src/watchdog/observers/inotify.py | |
@@ -688,6 +688,7 @@ if platform.is_linux(): | |
EventEmitter.__init__(self, event_queue, watch, timeout) | |
self._lock = threading.Lock() | |
self._inotify = Inotify(watch.path, watch.is_recursive) | |
+ self._moved_from_events = dict() | |
def on_thread_exit(self): | |
self._inotify.close() | |
@@ -695,10 +696,11 @@ if platform.is_linux(): | |
def queue_events(self, timeout): | |
with self._lock: | |
inotify_events = self._inotify.read_events() | |
- moved_from_events = dict() | |
+ if not any([event.is_moved_from or event.is_moved_to for event in inotify_events | |
+ self._moved_from_events = dict() | |
for event in inotify_events: | |
if event.is_moved_from: | |
- moved_from_events[event.cookie] = event | |
+ self._moved_from_events[event.cookie] = event | |
elif event.is_moved_to: | |
# TODO: Sometimes this line will bomb even when a previous | |
# moved_from event with the same cookie has fired. I have | |
@@ -708,7 +710,7 @@ if platform.is_linux(): | |
# for example, when you execute `git gc` in a monitored | |
# directory. | |
try: | |
- from_event = moved_from_events[event.cookie] | |
+ from_event = self._moved_from_events[event.cookie] | |
to_event = event | |
src_path = from_event.src_path | |
dest_path = to_event.src_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment