partially fix scrolling in files > 2 GB

This commit is contained in:
2021-10-31 13:53:17 +01:00
parent 79f9219e9a
commit bb99fb2c58
4 changed files with 27 additions and 9 deletions

View File

@@ -57,7 +57,7 @@ class LogFileModel:
return bytes.decode("utf8", errors="ignore")
def write_range(self, start_byte: int, end_byte: int, file: str):
print("write range: %d - %d -> %s" % (start_byte, end_byte, file))
# print("write range: %d - %d -> %s" % (start_byte, end_byte, file))
with self._lock, open(self._file, 'rb') as source, open(file, "w+b") as target:
offset = start_byte
source.seek(offset)
@@ -82,10 +82,9 @@ class LogFileModel:
# TODO abort file open after a few secons: https://docs.python.org/3/library/signal.html#example
with open(self._file, 'rb') as f:
offset = min(byte_offset, self.byte_count())
#print("offset: %s byte_count: %d" % (offset, self.byte_count()))
offset = max(0, offset - self.settings.max_line_length())
# print("offset: %s" % (offset))
eof_reached = True
f.seek(offset)
while l := f.readline():