From 938901d7aa82ed8559d3dc62f438b2826bf9af42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Fri, 30 Nov 2012 22:43:38 +0100 Subject: [PATCH] Fix issue with delete only transactions --- darc/store.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/darc/store.py b/darc/store.py index 634695214..21406f3c4 100644 --- a/darc/store.py +++ b/darc/store.py @@ -216,7 +216,9 @@ class Store(object): segment, _ = self.index[id] self.segments[segment] -= 1 self.compact.add(segment) - self.compact.add(self.io.write_delete(id)) + segment = self.io.write_delete(id) + self.segments.setdefault(segment, 0) + self.compact.add(segment) except KeyError: pass segment, offset = self.io.write_put(id, data) @@ -232,7 +234,9 @@ class Store(object): segment, offset = self.index.pop(id) self.segments[segment] -= 1 self.compact.add(segment) - self.compact.add(self.io.write_delete(id)) + segment = self.io.write_delete(id) + self.compact.add(segment) + self.segments.setdefault(segment, 0) except KeyError: raise self.DoesNotExist @@ -466,6 +470,22 @@ class StoreTestCase(unittest.TestCase): self.store.rollback() self.assertEqual(self.store.get('00000000000000000000000000000000'), 'foo') + def test_single_kind_transactions(self): + # put + self.store.put('00000000000000000000000000000000', 'foo') + self.store.commit() + self.store.close() + # replace + self.store = self.open() + self.store.put('00000000000000000000000000000000', 'bar') + self.store.commit() + self.store.close() + # delete + self.store = self.open() + self.store.delete('00000000000000000000000000000000') + self.store.commit() + + def suite(): return unittest.TestLoader().loadTestsFromTestCase(StoreTestCase)