summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-08-26 00:26:54 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-08-26 00:26:54 -0400
commit3d714c5cf767b23d56a18f704608df31b3b0ac2a (patch)
tree167545a2f3c3f5ec033bad78044fbf7e98a4b245
parentd5b52030348d40600b4c9256f76e5183a85fbb17 (diff)
fixed a Dropbox specific issue in NodeDirMonitor.
modified: TODO.org modified: combox/events.py
-rw-r--r--TODO.org2
-rw-r--r--combox/events.py24
2 files changed, 23 insertions, 3 deletions
diff --git a/TODO.org b/TODO.org
index 741eadf..156d661 100644
--- a/TODO.org
+++ b/TODO.org
@@ -119,3 +119,5 @@
must do it through setup.py
*** DONE Write the combox monitor startup thingy
DEADLINE: <2015-01-29 Thu>
+** unit tests
+*** TODO unit test the NodeDirMonitor.on_modified method for the special Dropbox thing.
diff --git a/combox/events.py b/combox/events.py
index c0bc224..33ff9d9 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -293,6 +293,24 @@ class NodeDirMonitor(LoggingEventHandler):
def on_moved(self, event):
super(NodeDirMonitor, self).on_moved(event)
+ silo_node_dict = 'file_moved'
+
+ if (not self.shardp(event.src_path) and
+ not self.shardp(event.dest_path) and
+ not event.is_directory):
+ # The file moved is of no importance.
+ return
+ if (not self.shardp(event.src_path) and
+ self.shardp(event.dest_path) and
+ not event.is_directory):
+ # This is Dropbox specific.
+ #
+ # The file is renamed to a shard; so this the first time
+ # the shard appears in this node directory -- it is
+ # created.
+
+ silo_node_dict = 'file_created'
+
src_cb_path = cb_path(event.src_path, self.config)
dest_cb_path = cb_path(event.dest_path, self.config)
@@ -300,8 +318,8 @@ class NodeDirMonitor(LoggingEventHandler):
# means this path was moved on another computer that is
# running combox.
with self.lock:
- self.silo.node_set('file_moved', src_cb_path)
- num = self.silo.node_get('file_moved', src_cb_path)
+ self.silo.node_set(silo_node_dict, src_cb_path)
+ num = self.silo.node_get(silo_node_dict, src_cb_path)
if num != self.num_nodes:
return
else:
@@ -309,7 +327,7 @@ class NodeDirMonitor(LoggingEventHandler):
os.rename(src_cb_path, dest_cb_path)
except OSError, e:
print "Jeez, failed to rename path.", e
- self.silo.node_rem('file_moved', src_cb_path)
+ self.silo.node_rem(silo_node_dict, src_cb_path)
if not event.is_directory:
self.silo.remove(src_cb_path)