Skip to content

Commit 2152e1e

Browse files
Merge pull request #9209 from ThomasWaldmann/fix-9208
Fix misc. borg transfer issues
2 parents 425fa1c + b43c3ad commit 2152e1e

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/borg/archiver/transfer_cmd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..helpers import location_validator, Location, archivename_validator, comment_validator
1111
from ..helpers import format_file_size, bin_to_hex
1212
from ..helpers import ChunkerParams, ChunkIteratorFileWrapper
13+
from ..item import ChunkListEntry
1314
from ..manifest import Manifest
1415
from ..legacyrepository import LegacyRepository
1516
from ..repository import Repository
@@ -84,7 +85,10 @@ def transfer_chunks(
8485
# A missing correct chunk in other_repository (source) will result in
8586
# a missing chunk in repository (destination).
8687
# We do NOT want to transfer all-zero replacement chunks from Borg 1 repositories.
87-
pass
88+
# But we want to have a correct chunks list entry. That will be useful in case the
89+
# chunk reappears, and also we could dynamically generate an all-zero replacement
90+
# of the correct size for reading / extracting, if desired.
91+
chunk_entry = ChunkListEntry(chunk_id, size)
8892
else:
8993
if recompress == "never":
9094
# Keep the compressed payload the same; verify via assert_id (that will

src/borg/helpers/fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class HardLinkManager:
346346
def __init__(self, *, id_type, info_type):
347347
self._map = {}
348348
self.id_type = id_type
349-
self.info_type = info_type
349+
self.info_type = info_type # can be a single type or a tuple of types
350350

351351
def borg1_hardlinkable(self, mode): # legacy
352352
return stat.S_ISREG(mode) or stat.S_ISBLK(mode) or stat.S_ISCHR(mode) or stat.S_ISFIFO(mode)

src/borg/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _get_archive_meta(self, id: bytes) -> dict:
151151
hostname=archive_item.hostname,
152152
size=archive_item.get("size", 0),
153153
nfiles=archive_item.get("nfiles", 0),
154-
comment=archive_item.comment, # not always present?
154+
comment=archive_item.get("comment", ""),
155155
tags=tuple(sorted(getattr(archive_item, "tags", []))), # must be hashable
156156
)
157157
return metadata

src/borg/upgrade.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from struct import Struct
2+
from types import NoneType
23

34
from .constants import REQUIRED_ITEM_KEYS, CH_BUZHASH
45
from .compress import ZLIB, ZLIB_legacy, ObfuscateSize
@@ -53,7 +54,8 @@ def __init__(self, *, cache, args):
5354

5455
def new_archive(self, *, archive):
5556
self.archive = archive
56-
self.hlm = HardLinkManager(id_type=bytes, info_type=list) # hlid -> chunks_correct
57+
# hlid -> chunks_correct list (or None, for contentless hardlinks)
58+
self.hlm = HardLinkManager(id_type=bytes, info_type=(list, NoneType))
5759

5860
def upgrade_item(self, *, item):
5961
"""Upgrades the item as needed and removes legacy data."""

0 commit comments

Comments
 (0)