mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-26 07:53:58 +00:00
repoobj: consistency / cleanups
This commit is contained in:
parent
acc5d9870a
commit
55b137bdae
1 changed files with 15 additions and 4 deletions
|
@ -114,14 +114,22 @@ def __init__(self, key):
|
|||
def id_hash(self, data: bytes) -> bytes:
|
||||
return self.key.id_hash(data)
|
||||
|
||||
def format(self, id: bytes, meta: dict, data: bytes, compress: bool = True, size: int = None) -> bytes:
|
||||
def format(
|
||||
self,
|
||||
id: bytes,
|
||||
meta: dict,
|
||||
data: bytes,
|
||||
compress: bool = True,
|
||||
size: int = None,
|
||||
ctype: int = None,
|
||||
clevel: int = None,
|
||||
) -> bytes:
|
||||
assert isinstance(id, bytes)
|
||||
assert meta == {}
|
||||
assert isinstance(data, (bytes, memoryview))
|
||||
assert compress or size is not None
|
||||
assert compress or size is not None
|
||||
assert compress or size is not None and ctype is not None and clevel is not None
|
||||
if compress:
|
||||
assert size is None
|
||||
assert size is None or size == len(data)
|
||||
meta, data_compressed = self.compressor.compress(meta, data)
|
||||
else:
|
||||
assert isinstance(size, int)
|
||||
|
@ -129,6 +137,9 @@ def format(self, id: bytes, meta: dict, data: bytes, compress: bool = True, size
|
|||
data_encrypted = self.key.encrypt(id, data_compressed)
|
||||
return data_encrypted
|
||||
|
||||
def parse_meta(self, id: bytes, cdata: bytes) -> dict:
|
||||
raise NotImplementedError("parse_meta is not available for RepoObj1")
|
||||
|
||||
def parse(self, id: bytes, cdata: bytes, decompress: bool = True) -> tuple[dict, bytes]:
|
||||
assert isinstance(id, bytes)
|
||||
assert isinstance(cdata, bytes)
|
||||
|
|
Loading…
Reference in a new issue