Make range requests closer to chunk size
This commit is contained in:
parent
a9ebcd79a0
commit
608ec9a6c3
3
lazip.py
3
lazip.py
|
@ -229,6 +229,9 @@ class Filazy(ReadOnlyBinaryIOWrapper):
|
|||
|
||||
def ensure(self, start: int, end: int) -> None:
|
||||
"""Download bytes from start to end inclusively."""
|
||||
offset = self.chunk_size - 1
|
||||
start = max(0, min(start, end-offset))
|
||||
end = min(self.length-1, max(end, start+offset))
|
||||
with self.stay():
|
||||
i, j = bisect_left(self.right, start), bisect_right(self.left, end)
|
||||
for start, end in self.merge(start, end, i, j):
|
||||
|
|
Loading…
Reference in New Issue