From fb12d1703a6ef266b7f30b54bcf1afc1bad381d5 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 22 Apr 2015 20:48:00 -0400 Subject: 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 --- combox/events.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'combox/events.py') 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) -- cgit v1.2.3