1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-12 15:20:20 +00:00

transfer: do not transfer replacement chunks, deal with missing chunks in other_repo

This commit is contained in:
Thomas Waldmann 2024-11-25 18:08:21 +01:00
parent 9ed75ca405
commit fa70d2f9c7
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -9,6 +9,8 @@ from ..helpers import Error
from ..helpers import location_validator, Location, archivename_validator, comment_validator from ..helpers import location_validator, Location, archivename_validator, comment_validator
from ..helpers import format_file_size, bin_to_hex from ..helpers import format_file_size, bin_to_hex
from ..manifest import Manifest from ..manifest import Manifest
from ..legacyrepository import LegacyRepository
from ..repository import Repository
from ..logger import create_logger from ..logger import create_logger
@ -111,13 +113,26 @@ class TransferMixIn:
# so let's remove them from old archives also, considering there is no # so let's remove them from old archives also, considering there is no
# code any more that deals with them in special ways (e.g. to get stats right). # code any more that deals with them in special ways (e.g. to get stats right).
continue continue
if "chunks" in item: if "chunks_healthy" in item: # legacy
other_chunks = item.chunks_healthy # chunks_healthy has the CORRECT chunks list, if present.
elif "chunks" in item:
other_chunks = item.chunks
else:
other_chunks = None
if other_chunks is not None:
chunks = [] chunks = []
for chunk_id, size in item.chunks: for chunk_id, size in other_chunks:
chunk_present = cache.seen_chunk(chunk_id, size) chunk_present = cache.seen_chunk(chunk_id, size)
if not chunk_present: # target repo does not yet have this chunk if not chunk_present: # target repo does not yet have this chunk
if not dry_run: if not dry_run:
try:
cdata = other_repository.get(chunk_id) cdata = other_repository.get(chunk_id)
except (Repository.ObjectNotFound, LegacyRepository.ObjectNotFound):
# missing correct chunk in other_repository (source) will result in
# a missing chunk in repository (destination).
# we do NOT want to transfer all-zero replacement chunks from borg1 repos.
pass
else:
if args.recompress == "never": if args.recompress == "never":
# keep compressed payload same, verify via assert_id (that will # keep compressed payload same, verify via assert_id (that will
# decompress, but avoid needing to compress it again): # decompress, but avoid needing to compress it again):