Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entirely read gzipped WARC files #35

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions warc/gzip2.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ def read_member(self):
if self._member_lock is False:
self._member_lock = True

if not self._new_member:
# the reader is in one of two possible states:
# 1. reached EOF
# 2. reached exactly the end of a Gzip member but not yet EOF
# Try to read 10 bytes (footer and Gzip magic number) to either
# - trigger an EOFError or
# - start the next member which also sets the "new member" state.
try:
BaseGzipFile._read(self, 10)
assert self._new_member is True
except EOFError:
return None

if self._new_member:
try:
# Read one byte to move to the next member
Expand Down