summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-12-21 19:46:26 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-12-21 19:46:26 -0500
commit8c86e7c28738c66c0e04ae7886b44dbcdfc6369e (patch)
treef82871e61278133137102a331111317d160234b3
parent8bb9f4568645771f464cf266a1b80146118a458e (diff)
Accounted for watchdog's weirdess.
This fixes two tests that were failing on OS X.
-rw-r--r--combox/events.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/combox/events.py b/combox/events.py
index 5b4ff0c..be37337 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -225,7 +225,17 @@ class ComboxDirMonitor(LoggingEventHandler):
else:
time.sleep(1)
- if self.just_created[event.src_path]:
+ # watchdog's weirdness
+ # --------------------
+ #
+ # On GNU/Linux, when a file is created, watchdog
+ # generates a 'file created' and a 'file modified'
+ # event; we're tracking this behaviour and ignoring
+ # the 'file modified' event.
+ #
+ if (self.just_created.has_key(event.src_path) and
+ self.just_created[event.src_path] and
+ platform.system() == 'Linux'):
self.just_created[event.src_path] = False
log_i("Just created file %s. So ignoring on_modified call." % (
event.src_path))
@@ -664,7 +674,17 @@ class NodeDirMonitor(LoggingEventHandler):
else:
time.sleep(1)
- if self.just_created[event.src_path]:
+ # watchdog's weirdness
+ # --------------------
+ #
+ # On GNU/Linux, when a file is created, watchdog generates
+ # a 'file created' and 'file modified' event; we're
+ # tracking this behaviour and ignoring the 'file modified'
+ # event.
+ #
+ if (self.just_created.has_key(event.src_path) and
+ self.just_created[event.src_path] and
+ platform.system() == 'Linux'):
self.just_created[event.src_path] = False
log_i("Just created file %s; ignoring on_modified call." % (
event.src_path))