summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-08-26 10:40:10 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-08-26 10:40:10 -0400
commit50fbaf03131bdf025b71d716879191a1db4fb172 (patch)
tree2fe4a28a2039da443207182ff798d01e5b8d11b3
parentef5cbad2f1aa2014853bde35596c0812d1c6b079 (diff)
combox/events.py: fixed a Dropox specific issue :|
-rw-r--r--combox/events.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/combox/events.py b/combox/events.py
index 7774bbd..de0196d 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -293,7 +293,11 @@ class NodeDirMonitor(LoggingEventHandler):
def on_moved(self, event):
super(NodeDirMonitor, self).on_moved(event)
+ src_cb_path = cb_path(event.src_path, self.config)
+ dest_cb_path = cb_path(event.dest_path, self.config)
+
silo_node_dict = 'file_moved'
+ cb_filename = src_cb_path
if (not self.shardp(event.src_path) and
not self.shardp(event.dest_path) and
@@ -309,6 +313,7 @@ class NodeDirMonitor(LoggingEventHandler):
# the shard appears in this node directory -- it is
# created.
silo_node_dict = 'file_created'
+ cb_filename = dest_cb_path
elif (self.shardp(event.src_path) and
self.shardp(event.dest_path) and
'.dropbox_cache' in event.dest_path and
@@ -320,17 +325,29 @@ class NodeDirMonitor(LoggingEventHandler):
# this treat as a file delete.
silo_node_dict = 'file_deleted'
- src_cb_path = cb_path(event.src_path, self.config)
- dest_cb_path = cb_path(event.dest_path, self.config)
-
if not path.exists(dest_cb_path):
# means this path was moved on another computer that is
# running combox.
with self.lock:
- self.silo.node_set(silo_node_dict, src_cb_path)
- num = self.silo.node_get(silo_node_dict, src_cb_path)
+ self.silo.node_set(silo_node_dict, cb_filename)
+ num = self.silo.node_get(silo_node_dict, cb_filename)
if num != self.num_nodes:
return
+ elif silo_node_dict == 'file_created':
+ # This is Dropbox specific :|
+ # create file in cb directory.
+ decrypt_and_glue(cb_filename, self.config)
+ # update db.
+ self.silo.update(cb_filename)
+ self.silo.node_rem('file_created', cb_filename)
+ elif silo_node_dict == 'file_deleted':
+ # This is Dropbox specify :|
+ # remove the corresponding file under the combox
+ # directory.
+ rm_path(cb_filename)
+ # remove file info from silo.
+ self.silo.remove(cb_filename)
+ self.silo.node_rem('file_deleted', cb_filename)
else:
try:
os.rename(src_cb_path, dest_cb_path)