Browse Source

check: remove orphan chunks detection/cleanup

This is now done in borg compact, so borg check does not need to care.
Thomas Waldmann 9 tháng trước cách đây
mục cha
commit
17ea118155
2 tập tin đã thay đổi với 1 bổ sung26 xóa
  1. 0 20
      src/borg/archive.py
  2. 1 6
      src/borg/testsuite/archiver/check_cmd.py

+ 0 - 20
src/borg/archive.py

@@ -1877,7 +1877,6 @@ class ArchiveChecker:
         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 @@ class ArchiveChecker:
                 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.")

+ 1 - 6
src/borg/testsuite/archiver/check_cmd.py

@@ -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"]])