mirror of https://github.com/borgbackup/borg.git
cleaner FileLikeWrapper with own __init__
This commit is contained in:
parent
9740767449
commit
e772d70e05
|
@ -13,6 +13,9 @@ logger = create_logger()
|
||||||
|
|
||||||
|
|
||||||
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 @@ class IntegrityCheckedFile(FileLikeWrapper):
|
||||||
# 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 New Issue