mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-25 23:43:49 +00:00
micro-opt: construct borg1_header_fmt Struct only once
This commit is contained in:
parent
e772d70e05
commit
360cd8488f
1 changed files with 4 additions and 3 deletions
|
@ -41,6 +41,8 @@ def upgrade_archive_metadata(self, *, metadata):
|
|||
|
||||
|
||||
class UpgraderFrom12To20:
|
||||
borg1_header_fmt = Struct(">I")
|
||||
|
||||
def __init__(self, *, cache):
|
||||
self.cache = cache
|
||||
|
||||
|
@ -126,10 +128,9 @@ def upgrade_zlib_and_level(meta, data):
|
|||
|
||||
if ctype == ObfuscateSize.ID:
|
||||
# in older borg, we used unusual byte order
|
||||
borg1_header_fmt = Struct(">I")
|
||||
hlen = borg1_header_fmt.size
|
||||
hlen = self.borg1_header_fmt.size
|
||||
csize_bytes = data[2 : 2 + hlen]
|
||||
csize = borg1_header_fmt.unpack(csize_bytes)[0]
|
||||
csize = self.borg1_header_fmt.unpack(csize_bytes)[0]
|
||||
compressed = data[2 + hlen : 2 + hlen + csize]
|
||||
meta, compressed = upgrade_zlib_and_level(meta, compressed)
|
||||
meta["psize"] = csize
|
||||
|
|
Loading…
Reference in a new issue