浏览代码

repoobj.format: mutate meta

we should modify the meta dict given by the caller, so the caller can know
about e.g. the compression/obfuscation that was done (this is useful for rcompress).
Thomas Waldmann 2 年之前
父节点
当前提交
acc5d9870a
共有 2 个文件被更改,包括 1 次插入2 次删除
  1. 0 1
      src/borg/repoobj.py
  2. 1 1
      src/borg/testsuite/repoobj.py

+ 0 - 1
src/borg/repoobj.py

@@ -35,7 +35,6 @@ class RepoObj:
     ) -> bytes:
     ) -> bytes:
         assert isinstance(id, bytes)
         assert isinstance(id, bytes)
         assert isinstance(meta, dict)
         assert isinstance(meta, dict)
-        meta = dict(meta)  # make a copy, so call arg is not modified
         assert isinstance(data, (bytes, memoryview))
         assert isinstance(data, (bytes, memoryview))
         assert compress or size is not None and ctype is not None and clevel is not None
         assert compress or size is not None and ctype is not None and clevel is not None
         if compress:
         if compress:

+ 1 - 1
src/borg/testsuite/repoobj.py

@@ -78,7 +78,7 @@ def test_borg1_borg2_transition(key):
     # note: as we did not decompress, we do not have "size" and we need to get it from somewhere else.
     # note: as we did not decompress, we do not have "size" and we need to get it from somewhere else.
     # here, we just use len_data. for borg transfer, we also know the size from another metadata source.
     # here, we just use len_data. for borg transfer, we also know the size from another metadata source.
     borg2_cdata = repo_objs2.format(
     borg2_cdata = repo_objs2.format(
-        id, meta1, compr_data1[2:], compress=False, size=len_data, ctype=meta1["ctype"], clevel=meta1["clevel"]
+        id, dict(meta1), compr_data1[2:], compress=False, size=len_data, ctype=meta1["ctype"], clevel=meta1["clevel"]
     )
     )
     meta2, data2 = repo_objs2.parse(id, borg2_cdata)
     meta2, data2 = repo_objs2.parse(id, borg2_cdata)
     assert data2 == data
     assert data2 == data