Skip to content

Commit

Permalink
Make gzip read as much gzip data as possible before moving on instead…
Browse files Browse the repository at this point in the history
… of causing an exception.
  • Loading branch information
keithjjones committed Oct 26, 2022
1 parent fed88c4 commit 078ceda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zat/zeek_multi_log_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def readrows(self):
if self._filepath.endswith('.gz'):
tmp = tempfile.NamedTemporaryFile(delete=False)
with gzip.open(self._filepath, 'rb') as f_in, open(tmp.name, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
try:
for line in f_in:
f_out.write(line)
except Exception as e:
print("Exception in {} : {}".format(self._filepath, e))

# Set the file path to the new temp file
self._filepath = tmp.name
Expand Down

0 comments on commit 078ceda

Please sign in to comment.