Guest User

Untitled

a guest
Jul 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. diff --git a/src/watchdog/observers/inotify.py b/src/watchdog/observers/inotify.py
  2. index 4ea8004..ac6136f 100644
  3. --- a/src/watchdog/observers/inotify.py
  4. +++ b/src/watchdog/observers/inotify.py
  5. @@ -688,6 +688,7 @@ if platform.is_linux():
  6. EventEmitter.__init__(self, event_queue, watch, timeout)
  7. self._lock = threading.Lock()
  8. self._inotify = Inotify(watch.path, watch.is_recursive)
  9. + self._moved_from_events = dict()
  10.  
  11. def on_thread_exit(self):
  12. self._inotify.close()
  13. @@ -695,10 +696,11 @@ if platform.is_linux():
  14. def queue_events(self, timeout):
  15. with self._lock:
  16. inotify_events = self._inotify.read_events()
  17. - moved_from_events = dict()
  18. + if not any([event.is_moved_from or event.is_moved_to for event in inotify_events
  19. + self._moved_from_events = dict()
  20. for event in inotify_events:
  21. if event.is_moved_from:
  22. - moved_from_events[event.cookie] = event
  23. + self._moved_from_events[event.cookie] = event
  24. elif event.is_moved_to:
  25. # TODO: Sometimes this line will bomb even when a previous
  26. # moved_from event with the same cookie has fired. I have
  27. @@ -708,7 +710,7 @@ if platform.is_linux():
  28. # for example, when you execute `git gc` in a monitored
  29. # directory.
  30. try:
  31. - from_event = moved_from_events[event.cookie]
  32. + from_event = self._moved_from_events[event.cookie]
  33. to_event = event
  34. src_path = from_event.src_path
  35. dest_path = to_event.src_path
Add Comment
Please, Sign In to add comment