From 106dfbadaee3f95c35390cc0686cf3bf05c36ade Mon Sep 17 00:00:00 2001 From: Mrityunjay Raj Date: Fri, 26 Jun 2026 23:24:57 +0530 Subject: [PATCH] tests: drop the delete_chunk wrapper, call Repository.delete directly Inline repository.delete at the check/extract/mount call sites. Drop the borgstore HEAD note from compact_pack now that it is fixed upstream. --- src/borg/repository.py | 5 ++--- src/borg/testsuite/archiver/__init__.py | 5 ----- src/borg/testsuite/archiver/check_cmd_test.py | 8 ++++---- src/borg/testsuite/archiver/extract_cmd_test.py | 3 +-- src/borg/testsuite/archiver/mount_cmds_test.py | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/borg/repository.py b/src/borg/repository.py index 730327374..591e5e383 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -856,9 +856,8 @@ class Repository: located.sort() # keep + drop tile the pack contiguously from offset 0; collect the objects to keep in the same - # pass. we do not cross-check against the pack's on-disk size: that needs a store.info() HEAD, - # which the stdio rest backend mishandles (it blocks reading a body the HEAD response never - # carries), and the caller already guarantees the two sets are the pack's complete object set. + # pass. we do not cross-check against the pack's on-disk size: the caller already guarantees the + # two sets are the pack's complete object set. kept = [] # (obj_offset, obj_id, obj_size), offset-ordered covered = 0 for offset, obj_id, size, keep in located: diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index 3631edd87..64422cb76 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -179,11 +179,6 @@ def open_archive(repo_path, name): return archive, repository -def delete_chunk(repository, id): - """Remove a single chunk from the repo, leaving the rest of its pack intact (test damage helper).""" - repository.delete(id) - - def open_repository(archiver): if archiver.get_kind() == "remote": return Repository(Location(archiver.repository_location), exclusive=True) diff --git a/src/borg/testsuite/archiver/check_cmd_test.py b/src/borg/testsuite/archiver/check_cmd_test.py index 5658c49da..13f5d2af9 100644 --- a/src/borg/testsuite/archiver/check_cmd_test.py +++ b/src/borg/testsuite/archiver/check_cmd_test.py @@ -11,7 +11,7 @@ from ...helpers import bin_to_hex, msgpack from ...manifest import Manifest from ...repository import Repository from ..repository_test import fchunk -from . import cmd, src_file, create_src_archive, open_archive, delete_chunk, generate_archiver_tests, RK_ENCRYPTION +from . import cmd, src_file, create_src_archive, open_archive, generate_archiver_tests, RK_ENCRYPTION pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA @@ -162,7 +162,7 @@ def test_missing_file_chunk(archivers, request): if item.path.endswith(src_file): valid_chunks = item.chunks killed_chunk = valid_chunks[-1] - delete_chunk(repository, killed_chunk.id) + repository.delete(killed_chunk.id) break else: pytest.fail("should not happen") # convert 'fail' @@ -198,7 +198,7 @@ def test_missing_archive_item_chunk(archivers, request): check_cmd_setup(archiver) archive, repository = open_archive(archiver.repository_path, "archive1") with repository: - delete_chunk(repository, archive.metadata.items[0]) + repository.delete(archive.metadata.items[0]) cmd(archiver, "check", exit_code=1) cmd(archiver, "check", "--repair", exit_code=0) cmd(archiver, "check", exit_code=0) @@ -209,7 +209,7 @@ def test_missing_archive_metadata(archivers, request): check_cmd_setup(archiver) archive, repository = open_archive(archiver.repository_path, "archive1") with repository: - delete_chunk(repository, archive.id) + repository.delete(archive.id) cmd(archiver, "check", exit_code=1) cmd(archiver, "check", "--repair", exit_code=0) cmd(archiver, "check", exit_code=0) diff --git a/src/borg/testsuite/archiver/extract_cmd_test.py b/src/borg/testsuite/archiver/extract_cmd_test.py index d1b1683a1..7a19d46b5 100644 --- a/src/borg/testsuite/archiver/extract_cmd_test.py +++ b/src/borg/testsuite/archiver/extract_cmd_test.py @@ -29,7 +29,6 @@ from . import ( generate_archiver_tests, create_src_archive, open_archive, - delete_chunk, src_file, ) @@ -801,7 +800,7 @@ def test_extract_file_with_missing_chunk(archivers, request): for item in archive.iter_items(): if item.path.endswith(src_file): chunk = item.chunks[-1] - delete_chunk(repository, chunk.id) + repository.delete(chunk.id) break else: assert False # missed the file diff --git a/src/borg/testsuite/archiver/mount_cmds_test.py b/src/borg/testsuite/archiver/mount_cmds_test.py index f55b1e4bd..c979ba4e3 100644 --- a/src/borg/testsuite/archiver/mount_cmds_test.py +++ b/src/borg/testsuite/archiver/mount_cmds_test.py @@ -20,7 +20,6 @@ from .. import changedir, filter_xattrs, same_ts_ns from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported from ..platform.platform_test import fakeroot_detected from . import RK_ENCRYPTION, cmd, assert_dirs_equal, create_regular_file, create_src_archive, open_archive, src_file -from . import delete_chunk from . import requires_hardlinks, _extract_hardlinks_setup, fuse_mount, create_test_files, generate_archiver_tests pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA @@ -235,7 +234,7 @@ def test_fuse_allow_damaged_files(archivers, request): with repository: for item in archive.iter_items(): if item.path.endswith(src_file): - delete_chunk(repository, item.chunks[-1].id) + repository.delete(item.chunks[-1].id) path = item.path # store full path for later break else: