mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
indexing: declare 'record' and bail if no record was loaded, add test for empty file indexing, fixes #168
This commit is contained in:
parent
fc5d7cc7cd
commit
bc84c2fda0
@ -80,6 +80,7 @@ class ArchiveIterator(object):
|
||||
|
||||
raise_invalid_gzip = False
|
||||
empty_record = False
|
||||
record = None
|
||||
|
||||
while True:
|
||||
try:
|
||||
@ -93,7 +94,8 @@ class ArchiveIterator(object):
|
||||
except EOFError:
|
||||
empty_record = True
|
||||
|
||||
self.read_to_end(record)
|
||||
if record:
|
||||
self.read_to_end(record)
|
||||
|
||||
if self.reader.decompressor:
|
||||
# if another gzip member, continue
|
||||
|
@ -329,6 +329,17 @@ com,example)/ 20140216050221 {"url": "http://example.com/", "digest": "PEWDX5GTH
|
||||
""")
|
||||
|
||||
|
||||
def test_cdxj_empty():
|
||||
options = dict(cdxj=True)
|
||||
|
||||
buff = BytesIO()
|
||||
|
||||
empty = BytesIO()
|
||||
|
||||
write_cdx_index(buff, empty, 'empty.warc.gz', **options)
|
||||
|
||||
assert buff.getvalue() == b''
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user