From 9d14db03da5d10d5ab0d7cc76b20e7b1ed5523bf Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Sat, 12 Sep 2015 22:04:15 -0400 Subject: fix for bug #6 Now, we check if the directory contains files, if it does, then we delay the deletion of the directory. --- combox/events.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/combox/events.py b/combox/events.py index d2a2b70..f83e351 100644 --- a/combox/events.py +++ b/combox/events.py @@ -521,8 +521,17 @@ class NodeDirMonitor(LoggingEventHandler): 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) + if os.listdir(file_cb_path): + # There are files under this directory that + # are not deleted yet, so we got to delay + # deletion :| + print "Marking", file_cb_path, "for later deletion." + delayed_thread = Timer(15, self.delete_later, + [file_cb_path]) + delayed_thread.start() + else: + 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): print event.src_path, "must have been deleted on another computer." with self.lock: -- cgit v1.2.3