From 098ae99641d5c848af1d0d25c29b254e7cd9d12e Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 15 Apr 2015 20:48:47 -0400 Subject: rewrote combox.events.NodeDirMonitor.on_deleted method. - Now the the node monitor waits for all shards of the file, which was deleted on a remote computer, to get deleted on this computer, before it finally deletes the respective file in the combox directory. - Tests for it is at tests.events_test.TestEvents.test_NDM_ondeleted method. modified: combox/events.py modified: tests/events_test.py Did some of this while listening to Cat Stevens' (Yusuf): - Just Another Night - Wild World - Father and son (*) - Peace train - Moonshadow (*) --- combox/events.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'combox/events.py') diff --git a/combox/events.py b/combox/events.py index bc6fe8b..3cb8ebd 100644 --- a/combox/events.py +++ b/combox/events.py @@ -339,13 +339,27 @@ class NodeDirMonitor(LoggingEventHandler): file_cb_path = cb_path(event.src_path, self.config) if event.is_directory: - # Delete corresponding directory under the combox directory. - rm_path(file_cb_path) + with self.lock: + self.silo.node_set('file_deleted', file_cb_path) + num = self.silo.node_get('file_deleted', file_cb_path) + + if num == self.num_nodes: + # Delete corresponding directory under the combox + # directory. + rm_path(file_cb_path) + self.silo.node_rem('file_deleted', file_cb_path) elif not event.is_directory and path.exists(file_cb_path): - # remove the corresponding file under the combox directory. - rm_path(file_cb_path) - # remove file info from silo. - self.silo.remove(file_cb_path) + with self.lock: + self.silo.node_set('file_deleted', file_cb_path) + num = self.silo.node_get('file_deleted', file_cb_path) + + if num == self.num_nodes: + # remove the corresponding file under the combox + # directory. + rm_path(file_cb_path) + # remove file info from silo. + self.silo.remove(file_cb_path) + self.silo.node_rem('file_deleted', file_cb_path) def on_modified(self, event): -- cgit v1.2.3