summaryrefslogtreecommitdiffstats
path: root/combox/events.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-04-15 20:48:47 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-04-15 20:48:47 -0400
commit098ae99641d5c848af1d0d25c29b254e7cd9d12e (patch)
tree0a95deb907b5a952ad42e288968617389f67c387 /combox/events.py
parent7c29a7dc5f592aff38e4c71a777a8cd6fdac9daf (diff)
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 (*)
Diffstat (limited to 'combox/events.py')
-rw-r--r--combox/events.py26
1 files changed, 20 insertions, 6 deletions
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):