combox

split and encrypted files between online file storage providers
git clone git://git.ricketyspace.net/combox.git
Log | Files | Refs

commit 3d714c5cf767b23d56a18f704608df31b3b0ac2a
parent d5b52030348d40600b4c9256f76e5183a85fbb17
Author: Siddharth Ravikumar <sravik@bgsu.edu>
Date:   Wed, 26 Aug 2015 00:26:54 -0400

fixed a Dropbox specific issue in NodeDirMonitor.

	modified:   TODO.org
	modified:   combox/events.py

Diffstat:
TODO.org | 2++
combox/events.py | 24+++++++++++++++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)

diff --git 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 @@ -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)