MCPcopy
hub / github.com/borgbackup/borg / test_uncommitted_garbage

Function test_uncommitted_garbage

src/borg/testsuite/legacyrepository_test.py:280–294  ·  view source on GitHub ↗
(repository)

Source from the content-addressed store, hash-verified

278
279
280def test_uncommitted_garbage(repository):
281 with repository:
282 # uncommitted garbage should be no problem, it is cleaned up automatically.
283 # we just have to be careful with invalidation of cached FDs in LoggedIO.
284 repository.put(H(0), fchunk(b"foo"))
285 repository.commit(compact=False)
286 # write some crap to an uncommitted segment file
287 last_segment = repository.io.get_latest_segment()
288 with open(repository.io.segment_filename(last_segment + 1), "wb") as f:
289 f.write(MAGIC + b"crapcrapcrap")
290 with reopen(repository) as repository:
291 # usually, opening the repo and starting a transaction should trigger a cleanup.
292 repository.put(H(0), fchunk(b"bar")) # this may trigger compact_segments()
293 repository.commit(compact=True)
294 # the point here is that nothing blows up with an exception.
295
296
297def test_replay_of_missing_index(repository):

Callers

nothing calls this directly

Calls 8

get_latest_segmentMethod · 0.80
segment_filenameMethod · 0.80
HFunction · 0.70
fchunkFunction · 0.70
reopenFunction · 0.70
putMethod · 0.45
commitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected