1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-26 07:53:58 +00:00

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).
This commit is contained in:
Thomas Waldmann 2022-09-21 10:09:35 +02:00
parent d671707226
commit acc5d9870a
2 changed files with 1 additions and 2 deletions

View file

@ -35,7 +35,6 @@ def format(
) -> 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:

View file

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