Merge pull request #7012 from ThomasWaldmann/separate-encrypted-metadata

2 more things...
This commit is contained in:
TW 2022-09-09 22:53:01 +02:00 committed by GitHub
commit c5352000a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -4,7 +4,7 @@ from ._common import with_repository, with_other_repository
from ..archive import Archive
from ..constants import * # NOQA
from ..crypto.key import uses_same_id_hash, uses_same_chunker_secret
from ..helpers import EXIT_SUCCESS, EXIT_ERROR
from ..helpers import EXIT_SUCCESS, EXIT_ERROR, Error
from ..helpers import location_validator, Location
from ..helpers import format_file_size
from ..manifest import Manifest
@ -47,6 +47,9 @@ class TransferMixIn:
self.print_error(f"No such upgrader: {args.upgrader}")
return EXIT_ERROR
if UpgraderCls is not upgrade_mod.UpgraderFrom12To20 and other_manifest.repository.version == 1:
raise Error("To transfer from a borg 1.x repo, you need to use: --upgrader=From12To20")
upgrader = UpgraderCls(cache=cache)
for name in archive_names:

View file

@ -123,8 +123,10 @@ class UpgraderFrom12To20:
csize = borg1_header_fmt.unpack(csize_bytes)
compressed = data[2 + hlen : 2 + hlen + csize]
meta, compressed = upgrade_zlib_and_level(meta, compressed)
meta["psize"] = csize
osize = len(data) - 2 - hlen - csize # amount of 0x00 bytes appended for obfuscation
data = compressed + bytes(osize)
meta["csize"] = len(data)
else:
meta, data = upgrade_zlib_and_level(meta, data)
return meta, data