Skip to content

Commit

Permalink
Merge pull request #7712 from ThomasWaldmann/manifest-item_keys
Browse files Browse the repository at this point in the history
manifest: move item_keys into config dict, fixes #7710
  • Loading branch information
ThomasWaldmann authored Jul 6, 2023
2 parents cfbfe24 + 51e68c2 commit 7914e38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ per_file_ignores =
src/borg/testsuite/__init__.py:E501,F401
src/borg/testsuite/archive.py:E128,W504
src/borg/testsuite/archiver/__init__.py:E128,E501,E722,F401,F405,F811
src/borg/testsuite/archiver/debug_cmds.py:E501
src/borg/testsuite/archiver/debug_cmds.py:E501,F405
src/borg/testsuite/archiver/disk_full.py:F401,F405,F811
src/borg/testsuite/archiver/extract_cmd.py:F405
src/borg/testsuite/archiver/mount_cmds.py:E501,E722
Expand Down
4 changes: 2 additions & 2 deletions src/borg/item.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ cdef class ManifestItem(PropDict):
archives = PropDictProperty(dict, 'dict of str -> dict') # name -> dict
timestamp = PropDictProperty(str)
config = PropDictProperty(dict)
item_keys = PropDictProperty(tuple, 'tuple of str')
item_keys = PropDictProperty(tuple, 'tuple of str') # legacy. new location is inside config.

def update_internal(self, d):
# legacy support for migration (data from old msgpacks comes in as bytes always, but sometimes we want str)
Expand Down Expand Up @@ -650,7 +650,7 @@ class ItemDiff:
self._can_compare_chunk_ids = can_compare_chunk_ids
self._chunk_1 = chunk_1
self._chunk_2 = chunk_2

self._changes = {}

if self._item1.is_link() or self._item2.is_link():
Expand Down
8 changes: 5 additions & 3 deletions src/borg/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def load(cls, repository, operations, key=None, force_tam_not_required=False, *,
manifest.timestamp = m.get("timestamp")
manifest.config = m.config
# valid item keys are whatever is known in the repo or every key we know
manifest.item_keys = ITEM_KEYS | frozenset(m.get("item_keys", []))
manifest.item_keys = ITEM_KEYS
manifest.item_keys |= frozenset(m.config.get("item_keys", [])) # new location of item_keys since borg2
manifest.item_keys |= frozenset(m.get("item_keys", [])) # legacy: borg 1.x: item_keys not in config yet

if manifest.tam_verified:
manifest_required = manifest.config.get("tam_required", False)
Expand Down Expand Up @@ -321,12 +323,12 @@ def write(self):
assert len(self.archives) <= MAX_ARCHIVES
assert all(len(name) <= 255 for name in self.archives)
assert len(self.item_keys) <= 100
self.config["item_keys"] = tuple(sorted(self.item_keys))
manifest = ManifestItem(
version=1,
version=2,
archives=StableDict(self.archives.get_raw_dict()),
timestamp=self.timestamp,
config=StableDict(self.config),
item_keys=tuple(sorted(self.item_keys)),
)
self.tam_verified = True
data = self.key.pack_and_authenticate_metadata(manifest.as_dict())
Expand Down
3 changes: 2 additions & 1 deletion src/borg/testsuite/archiver/debug_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def test_debug_dump_manifest(self):
result = json.load(f)
assert "archives" in result
assert "config" in result
assert "item_keys" in result
assert "item_keys" in result["config"]
assert frozenset(result["config"]["item_keys"]) == ITEM_KEYS
assert "timestamp" in result
assert "version" in result

Expand Down

0 comments on commit 7914e38

Please sign in to comment.