mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
cleaner FileLikeWrapper with own __init__
This commit is contained in:
parent
9740767449
commit
e772d70e05
1 changed files with 6 additions and 2 deletions
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
|
|
||||||
class FileLikeWrapper:
|
class FileLikeWrapper:
|
||||||
|
def __init__(self, fd):
|
||||||
|
self.fd = fd
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.fd.__enter__()
|
self.fd.__enter__()
|
||||||
return self
|
return self
|
||||||
|
@ -59,7 +62,7 @@ class FileHashingWrapper(FileLikeWrapper):
|
||||||
FACTORY: Callable = None
|
FACTORY: Callable = None
|
||||||
|
|
||||||
def __init__(self, backing_fd, write):
|
def __init__(self, backing_fd, write):
|
||||||
self.fd = backing_fd
|
super().__init__(backing_fd)
|
||||||
self.writing = write
|
self.writing = write
|
||||||
self.hash = self.FACTORY()
|
self.hash = self.FACTORY()
|
||||||
|
|
||||||
|
@ -142,7 +145,8 @@ def __init__(self, path, write, filename=None, override_fd=None, integrity_data=
|
||||||
# TODO: When we're reading but don't have any digests, i.e. no integrity file existed,
|
# TODO: When we're reading but don't have any digests, i.e. no integrity file existed,
|
||||||
# TODO: then we could just short-circuit.
|
# TODO: then we could just short-circuit.
|
||||||
|
|
||||||
self.fd = self.hasher = hash_cls(backing_fd=self.file_fd, write=write)
|
self.hasher = hash_cls(backing_fd=self.file_fd, write=write)
|
||||||
|
super().__init__(self.hasher)
|
||||||
self.hash_filename(filename)
|
self.hash_filename(filename)
|
||||||
|
|
||||||
def load_integrity_data(self, path, integrity_data):
|
def load_integrity_data(self, path, integrity_data):
|
||||||
|
|
Loading…
Reference in a new issue