1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

cleaner FileLikeWrapper with own __init__

This commit is contained in:
Thomas Waldmann 2023-01-30 03:31:27 +01:00
parent 9740767449
commit e772d70e05
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -13,6 +13,9 @@
class FileLikeWrapper:
def __init__(self, fd):
self.fd = fd
def __enter__(self):
self.fd.__enter__()
return self
@ -59,7 +62,7 @@ class FileHashingWrapper(FileLikeWrapper):
FACTORY: Callable = None
def __init__(self, backing_fd, write):
self.fd = backing_fd
super().__init__(backing_fd)
self.writing = write
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: 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)
def load_integrity_data(self, path, integrity_data):