Skip to content

Commit

Permalink
inotify: correctly report deletion of the watched directory
Browse files Browse the repository at this point in the history
IN_DELETE_SELF is does not have the IN_ISDIR flag set (kernel issue?).
Have InotifyEvent.is_directory return True in this case.
  • Loading branch information
kreichgauer committed Sep 22, 2011
1 parent 0656443 commit 74ec8af
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/watchdog/observers/inotify.py
Expand Up @@ -322,6 +322,10 @@ def is_moved_to(self):
def is_move(self):
return self._mask & InotifyConstants.IN_MOVE > 0

@property
def is_move_self(self):
return self._mask & InotifyConstants.IN_MOVE_SELF > 0

@property
def is_attrib(self):
return self._mask & InotifyConstants.IN_ATTRIB > 0
Expand All @@ -333,6 +337,11 @@ def is_ignored(self):

@property
def is_directory(self):
# It looks like the kernel does not provide this information for
# IN_DELETE_SELF and IN_MOVE_SELF. In this case, assume it's a dir.
# See also: https://github.com/seb-m/pyinotify/blob/2c7e8f8/python2/pyinotify.py#L897
if self.is_delete_self or self.is_move_self:
return True
return self._mask & InotifyConstants.IN_ISDIR > 0

# Python-specific functionality.
Expand Down

0 comments on commit 74ec8af

Please sign in to comment.