summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-02-25 22:40:22 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-02-25 22:40:22 -0500
commit2511b80565206f40f7059376ab876999c7adaae7 (patch)
treef24b69050a7f610bb8e8e09a894c4a72ed6aac17
parente6669c8971cd3f3dd8fd1de5608b9bd4ebcecef6 (diff)
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
-rw-r--r--combox/events.py9
1 files 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.