Add a tell() method to PatchFile to track how much has been written
This commit is contained in:
parent
f6e518d2f9
commit
3a373a200c
@ -120,6 +120,11 @@ class PatchFile(StreamingJob):
|
||||
job = begin_patch(self.read_from_src)
|
||||
super().__init__(job, output_buf_size=4 * IO_BUFFER_SIZE)
|
||||
|
||||
def tell(self) -> int:
|
||||
if self.dest_file.closed:
|
||||
return os.path.getsize(self.src_file.name if self.overwrite_src else self.dest_file.name)
|
||||
return self.dest_file.tell()
|
||||
|
||||
def read_from_src(self, b: memoryview, pos: int) -> int:
|
||||
self.src_file.seek(pos)
|
||||
return self.src_file.readinto(b) # type: ignore
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user