Skip to content

Commit

Permalink
Remove duplicated directory "delete" on Linux
Browse files Browse the repository at this point in the history
Inotify emits a IN_DELETE|IS_DIR event and a IN_DELETE_SELF event (in
this order) when a watched directory is removed, the former event
happens for all directories and generates a pair of a DirDeletedEvent
and a DirModifiedEvent instances, the latter used to generate a
(duplicated and unrequired) DirDeletedEvent

With this change, the test_fast_subdirectory_creation_deletion no
longer fails
  • Loading branch information
danilobellini committed Sep 24, 2016
1 parent 69d4ca4 commit ca335db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/watchdog/observers/inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ def queue_events(self, timeout, full_events=False):
elif event.is_modify:
cls = DirModifiedEvent if event.is_directory else FileModifiedEvent
self.queue_event(cls(src_path))
elif event.is_delete_self:
cls = DirDeletedEvent if event.is_directory else FileDeletedEvent
self.queue_event(cls(src_path))
elif event.is_delete or (event.is_moved_from and not full_events):
cls = DirDeletedEvent if event.is_directory else FileDeletedEvent
self.queue_event(cls(src_path))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from watchdog.observers.inotify import InotifyFullEmitter

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


def setup_function(function):
Expand Down Expand Up @@ -217,6 +218,7 @@ def test_fast_subdirectory_creation_deletion():
DirDeletedEvent: sub_dir}
for unused in range(times * 4):
event = event_queue.get(timeout=5)[0]
logger.debug(event)
etype = type(event)
count[etype] += 1
assert event.src_path == etype_for_dir[etype]
Expand Down

0 comments on commit ca335db

Please sign in to comment.