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:
parent
177569d87b
commit
938901d7aa
1 changed files with 22 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue