From d26dfc87e40dfb34481edbed75e0200931e9a815 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Tue, 31 Mar 2015 17:40:03 -0400 Subject: ComboxSilo is now going to have dictionaries that track information about the shards. modified: combox/events.py modified: combox/silo.py --- combox/events.py | 11 +++++++++-- combox/silo.py | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/combox/events.py b/combox/events.py index bf9ad1d..fa47ceb 100644 --- a/combox/events.py +++ b/combox/events.py @@ -81,7 +81,10 @@ class ComboxDirMonitor(LoggingEventHandler): print "Thanks for your patience." # Remove information about files that were deleted. - for fpath in self.silo.keys(): + fpath_filter = lambda x: x not in self.silo.nodedicts() + fpaths = filter(fpath_filter, self.silo.keys()) + + for fpath in fpaths: if not path.exists(fpath): # remove this file's info from silo. print fpath, "was deleted. Removing it from DB." @@ -238,7 +241,11 @@ class NodeDirMonitor(LoggingEventHandler): # Remove files from the combox directory whose shards were # deleted. - for fpath in self.silo.keys(): + # Remove information about files that were deleted. + fpath_filter = lambda x: x not in self.silo.nodedicts() + fpaths = filter(fpath_filter, self.silo.keys()) + + for fpath in fpaths: fshards = node_paths(fpath, self.config, True) for fshard in fshards: diff --git a/combox/silo.py b/combox/silo.py index a2a6b9b..4f5b746 100644 --- a/combox/silo.py +++ b/combox/silo.py @@ -39,6 +39,15 @@ class ComboxSilo(object): silo = path.join(config['silo_dir'], 'silo.db') self.db = pickledb.load(silo, True) + ## things we need for housekeep the node directory. + self.node_dicts = ['shard_created', 'shard_modified', 'shard_moved', + 'shard_deleted'] + + # created the dicts if not already created. + for ndict in self.node_dicts: + if not self.db.get(ndict): + self.db.dcreate(ndict) + self.lock = Lock() -- cgit v1.2.3