1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-24 06:59:52 +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:
Ilya Kreymer 2016-03-09 07:27:03 -08:00
parent fc5d7cc7cd
commit bc84c2fda0
2 changed files with 14 additions and 1 deletions

View File

@ -80,6 +80,7 @@ class ArchiveIterator(object):
raise_invalid_gzip = False raise_invalid_gzip = False
empty_record = False empty_record = False
record = None
while True: while True:
try: try:
@ -93,7 +94,8 @@ class ArchiveIterator(object):
except EOFError: except EOFError:
empty_record = True empty_record = True
self.read_to_end(record) if record:
self.read_to_end(record)
if self.reader.decompressor: if self.reader.decompressor:
# if another gzip member, continue # if another gzip member, continue

View File

@ -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__": if __name__ == "__main__":