1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-29 11:16:43 +00:00

check: remove orphan chunks detection/cleanup

This is now done in borg compact, so borg check does not need to care.
This commit is contained in:
Thomas Waldmann 2024-08-13 22:52:14 +02:00
parent 8ef517161d
commit 17ea118155
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 1 additions and 26 deletions

View file

@ -1877,7 +1877,6 @@ def check(
self.rebuild_refcounts(
match=match, first=first, last=last, sort_by=sort_by, older=older, oldest=oldest, newer=newer, newest=newest
)
self.orphan_chunks_check()
self.finish()
if self.error_found:
logger.error("Archive consistency check complete, problems found.")
@ -2346,25 +2345,6 @@ def valid_item(obj):
self.manifest.archives[info.name] = (new_archive_id, info.ts)
pi.finish()
def orphan_chunks_check(self):
if self.check_all:
unused = {id_ for id_, entry in self.chunks.iteritems() if entry.refcount == 0}
orphaned = unused - self.possibly_superseded
if orphaned:
logger.info(f"{len(orphaned)} orphaned (unused) objects found.")
for chunk_id in orphaned:
logger.debug(f"chunk {bin_to_hex(chunk_id)} is orphaned.")
# To support working with AdHocCache or AdHocWithFilesCache, we do not set self.error_found = True.
if self.repair and unused:
logger.info(
"Deleting %d orphaned and %d superseded objects..." % (len(orphaned), len(self.possibly_superseded))
)
for id_ in unused:
self.repository.delete(id_)
logger.info("Finished deleting orphaned/superseded objects.")
else:
logger.info("Orphaned objects check skipped (needs all archives checked).")
def finish(self):
if self.repair:
logger.info("Writing Manifest.")

View file

@ -355,12 +355,7 @@ def test_extra_chunks(archivers, request):
chunk = fchunk(b"xxxx")
repository.put(b"01234567890123456789012345678901", chunk)
repository.commit(compact=False)
output = cmd(archiver, "check", "-v", exit_code=0) # orphans are not considered warnings anymore
assert "1 orphaned (unused) objects found." in output
cmd(archiver, "check", "--repair", exit_code=0)
output = cmd(archiver, "check", "-v", exit_code=0)
assert "orphaned (unused) objects found." not in output
cmd(archiver, "extract", "archive1", "--dry-run", exit_code=0)
cmd(archiver, "check", "-v", exit_code=0) # check does not deal with orphans anymore
@pytest.mark.parametrize("init_args", [["--encryption=repokey-aes-ocb"], ["--encryption", "none"]])