Skip to content

Commit

Permalink
Fix joh#30: Remove set of watched directories
Browse files Browse the repository at this point in the history
pyinotify will ignore paths which already have a watch, so it's safe to
call add_watch() multiple times for the same path.
  • Loading branch information
Johannes Jensen committed Jun 17, 2015
1 parent 1e3bded commit da15613
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions whenchanged/whenchanged.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ def run(self):
pyinotify.IN_MOVED_TO |
pyinotify.IN_CREATE)

watched = set()
for p in self.paths:
if os.path.isdir(p) and not p in watched:
if os.path.isdir(p):
# Add directory
wdd = wm.add_watch(p, mask, rec=self.recursive,
auto_add=self.recursive)
else:
# Add parent directory
path = os.path.dirname(p)
if not path in watched:
wdd = wm.add_watch(path, mask)
wdd = wm.add_watch(path, mask)

notifier.loop()

Expand Down

0 comments on commit da15613

Please sign in to comment.