Browse Source

Make range requests closer to chunk size

master
Nguyễn Gia Phong 2 years ago
parent
commit
608ec9a6c3
  1. 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…
Cancel
Save