From 8c86e7c28738c66c0e04ae7886b44dbcdfc6369e Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Mon, 21 Dec 2015 19:46:26 -0500 Subject: Accounted for watchdog's weirdess. This fixes two tests that were failing on OS X. --- combox/events.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'combox') 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)) -- cgit v1.2.3