summaryrefslogtreecommitdiffstats
path: root/combox
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-04-22 20:48:00 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-04-22 20:48:00 -0400
commitfb12d1703a6ef266b7f30b54bcf1afc1bad381d5 (patch)
tree87d0e406b3a848269b75495db467b756dfc15a88 /combox
parent36f4b913fabd2db02b92d114a910011c114da591 (diff)
rewrote combox.events.NodeDirMonitor.on_moved method.
- Now the node monitor waits for all shards of the file, which was moved/renamed on a remote computer, to get moved/renamed on this computer, before it finally reconstructs the moved/renamed file in the combox directory on this computer. - Updated the tests for on_moved method at tests.events_test.TestEvents.test_NDM_onmoved method. modified: combox/events.py modified: tests/events_test.py
Diffstat (limited to 'combox')
-rw-r--r--combox/events.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/combox/events.py b/combox/events.py
index 3cb8ebd..7026756 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -281,10 +281,17 @@ class NodeDirMonitor(LoggingEventHandler):
if not path.exists(dest_cb_path):
# means this path was move on another computer that is
# running combox.
- try:
- os.rename(src_cb_path, dest_cb_path)
- except OSError, e:
- print "Jeez, failed to rename path.", e
+ with self.lock:
+ self.silo.node_set('file_moved', src_cb_path)
+ num = self.silo.node_get('file_moved', src_cb_path)
+ if num != self.num_nodes:
+ return
+ else:
+ try:
+ 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)
if not event.is_directory:
self.silo.remove(src_cb_path)