Selaa lähdekoodia

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.
Thomas Waldmann 5 päivää sitten
vanhempi
sitoutus
3bda2f10d9
2 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 1 1
      src/borg/helpers/fs.py
  2. 3 1
      src/borg/upgrade.py

+ 1 - 1
src/borg/helpers/fs.py

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

+ 3 - 1
src/borg/upgrade.py

@@ -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."""