1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-31 03:31:41 +00:00

Fix issue with delete only transactions

This commit is contained in:
Jonas Borgström 2012-11-30 22:43:38 +01:00
parent 177569d87b
commit 938901d7aa

View file

@ -216,7 +216,9 @@ def put(self, id, data, wait=True):
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 @@ def delete(self, id, wait=True):
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 @@ def test_consistency2(self):
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)