From 9d8e75ba25fcb39e98a49c3ab6e81759d6d468e4 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Mon, 8 Sep 2014 00:08:41 +0000 Subject: #51 - fixes bug in which TagIndex.remove were not visible to other TagIndex instances --- service/pixelated/adapter/tag_index.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'service/pixelated/adapter/tag_index.py') diff --git a/service/pixelated/adapter/tag_index.py b/service/pixelated/adapter/tag_index.py index 743c74e1..3cdeb1d8 100644 --- a/service/pixelated/adapter/tag_index.py +++ b/service/pixelated/adapter/tag_index.py @@ -31,8 +31,7 @@ class TagIndex: 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') + self._flush() def add(self, tag): if tag.name not in self.db: @@ -47,6 +46,7 @@ class TagIndex: def remove(self, tag_name): if tag_name in self.db: del self.db[tag_name] + self._flush() def empty(self): return len(self.db.keys()) == 0 @@ -56,3 +56,7 @@ class TagIndex: def close_db(self): self.db.close() + + def _flush(self): + self.close_db() + self.db = dbm.open(self.db_path, 'c') -- cgit v1.2.3