respect range limit when searching

This commit is contained in:
2022-12-17 18:35:22 +01:00
parent b8433306fa
commit 9c311f8c67
3 changed files with 16 additions and 0 deletions

View File

@@ -68,12 +68,19 @@ class FilterTask(QRunnable):
last_progress_report = time.time()
try:
with open(self.source_model.get_file(), "rb") as source:
source.seek(self.source_model.range_start)
source_position = source.tell()
with open(self.filter_model.get_file(), "w+b") as target:
line_count = 0
lines_written = 0
while line_encoded := source.readline():
if 0 < self.source_model.range_end < source_position:
break
line_count = line_count + 1
line = line_encoded.decode("utf8", errors="ignore")
source_position = source_position + len(line_encoded)
if self.regex.findall(line):
lines_written = lines_written + 1