summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPatrick Maia and Victor Shyba <pixelated-team+pmaia+vshyba@thoughtworks.com>2014-09-06 23:24:55 +0000
committerPatrick Maia <pmaia@thoughtworks.com>2014-09-06 23:24:55 +0000
commit0b7fd19efba22ebf4270a3be0677e3f83d4a8aaf (patch)
tree4063818dddb784c679992ce4fdbd28c590a9107b /service
parentbbf12cbf48d9143a6920a80193ff29fc42cce646 (diff)
#51 - forces tag index to be flushed after a tag is set
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/tag_index.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/service/pixelated/adapter/tag_index.py b/service/pixelated/adapter/tag_index.py
index 6cc2a68d..25108643 100644
--- a/service/pixelated/adapter/tag_index.py
+++ b/service/pixelated/adapter/tag_index.py
@@ -24,12 +24,15 @@ class TagIndex:
Manages an index for mail's tags using a file storage.
"""
- def __init__(self, filename):
- self.db = dbm.open(filename, 'c')
+ def __init__(self, db_path):
+ self.db_path = db_path
+ self.db = dbm.open(db_path, 'c')
atexit.register(self.close_db)
def set(self, tag):
self.db[tag.name] = tag.as_json_string()
+ self.close_db() # force flush
+ self.db = dbm.open(self.db_path, 'c')
def get(self, tag_name):
if tag_name in self.db: