From c3b737ccb642aeec4f19e08c9c8185c63d1c7162 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Mon, 7 Sep 2015 19:27:48 -0400 Subject: combox.events: plaftorm specific changes. In NodeDirMonitor's on_moved method, when we detect that a shard is modified, we push the info, about the shard modification, to silo from the on_moved for the OS X platform. --- combox/events.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/combox/events.py b/combox/events.py index baa4b44..d2a2b70 100644 --- a/combox/events.py +++ b/combox/events.py @@ -17,6 +17,7 @@ # . import os +import platform import logging from os import path @@ -386,13 +387,25 @@ class NodeDirMonitor(LoggingEventHandler): print "Okay, %s (%s) was actually modified." % (cb_filename, event.dest_path) self.silo.node_rem('file_deleted', cb_filename) - self.silo.node_set('file_modified', cb_filename) - num = self.silo.node_get('file_modified', cb_filename) - if num == self.num_nodes: - decrypt_and_glue(cb_filename, self.config) - # update db. - self.silo.update(cb_filename) - self.silo.node_rem('file_modified', cb_filename) + # Next, if we're on GNU/Linux, watchdog detects that + # the shard was modified and generates calls the + # on_modified method. So we don't have to store + # information in the silo about this shard being + # modified; we do that later in the on_modified + # method. + # + # But, on OS X (a.k.a Darwin), watchdog detect the + # shard is modified and does not generate a call to + # the on_modified method. So we store the information + # about the modified shard here itself. + if platform.system() == 'Darwin': + self.silo.node_set('file_modified', cb_filename) + num = self.silo.node_get('file_modified', cb_filename) + if num == self.num_nodes: + decrypt_and_glue(cb_filename, self.config) + # update db. + self.silo.update(cb_filename) + self.silo.node_rem('file_modified', cb_filename) return -- cgit v1.2.3