From 2511b80565206f40f7059376ab876999c7adaae7 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 25 Feb 2015 22:40:22 -0500 Subject: updated combox.events.ComboxDirMonitor.on_create method Now the file shards or directory is created in the node directories only if they don't already exist; if they exist that means this file was created from another computer (also running combox). modified: combox/events.py --- combox/events.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/combox/events.py b/combox/events.py index c466139..779b6f6 100644 --- a/combox/events.py +++ b/combox/events.py @@ -26,7 +26,7 @@ from watchdog.events import LoggingEventHandler from combox.crypto import split_and_encrypt, decrypt_and_glue from combox.file import (mk_nodedir, rm_nodedir, rm_shards, relative_path, move_shards, move_nodedir, - cb_path) + cb_path, node_path) from combox.silo import ComboxSilo @@ -120,10 +120,13 @@ class ComboxDirMonitor(LoggingEventHandler): def on_created(self, event): super(ComboxDirMonitor, self).on_created(event) - if event.is_directory: + file_node_path = node_path(event.src_path, self.config) + + if event.is_directory and (not path.exists(file_node_path)): # creates a corresponding directory at the node dirs. mk_nodedir(event.src_path, self.config) - else: + elif (not event.is_directory) and (not path.exists( + file_node_path)): # file was created split_and_encrypt(event.src_path, self.config) # store file info in silo. -- cgit v1.2.3