HardLinkManager: allow NoneType for contentless hardlinks, see #9208

Some hardlinks have content and thus a chunks list,
but e.g. block or char device hardlinks do not have a chunks list.
This commit is contained in:
Thomas Waldmann 2025-12-04 23:32:05 +01:00
parent 352f982393
commit 3bda2f10d9
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 4 additions and 2 deletions

View file

@ -346,7 +346,7 @@ class HardLinkManager:
def __init__(self, *, id_type, info_type):
self._map = {}
self.id_type = id_type
self.info_type = info_type
self.info_type = info_type # can be a single type or a tuple of types
def borg1_hardlinkable(self, mode): # legacy
return stat.S_ISREG(mode) or stat.S_ISBLK(mode) or stat.S_ISCHR(mode) or stat.S_ISFIFO(mode)

View file

@ -1,4 +1,5 @@
from struct import Struct
from types import NoneType
from .constants import REQUIRED_ITEM_KEYS, CH_BUZHASH
from .compress import ZLIB, ZLIB_legacy, ObfuscateSize
@ -53,7 +54,8 @@ class UpgraderFrom12To20:
def new_archive(self, *, archive):
self.archive = archive
self.hlm = HardLinkManager(id_type=bytes, info_type=list) # hlid -> chunks_correct
# hlid -> chunks_correct list (or None, for contentless hardlinks)
self.hlm = HardLinkManager(id_type=bytes, info_type=(list, NoneType))
def upgrade_item(self, *, item):
"""Upgrades the item as needed and removes legacy data."""