# HG changeset patch # User Henry S. Thompson # Date 1689253322 -3600 # Node ID 7b68c3ebc35a045caae178fba443c4742d4dccc2 # Parent 5d40d7511374cbd10e7e680a064a94847d375898 tests 1 & 2 now working diff -r 5d40d7511374 -r 7b68c3ebc35a bin/warc.py --- a/bin/warc.py Thu Jul 13 11:28:24 2023 +0100 +++ b/bin/warc.py Thu Jul 13 14:02:02 2023 +0100 @@ -72,17 +72,25 @@ keepFrom=start_1 keepLen=bl-keepFrom buf[0:keepLen]=bufView[keepFrom:bl] + eol=eol-start_1 + start_1=0 + bp=eol+2 else: # we can skip the rest of this part - keepLen=0 - fpos=stream.seek(fpos+(bp+length-bl)) + if (bp+length)<=bl: + # we have at least some bytes from the next part + keepLen=bl-(bp+length) + buf[0:keepLen]=bufView[bl-keepLen:bl] + else: + # we don't have all of the bytes from the current part + # so can skip the rest of it + keepLen=0 + fpos=stream.seek(fpos+(bp+length-bl)) + bp=0 spaceToFill=bufSize-keepLen with memoryview(buf)[keepLen:bufSize] as xBuf: nb=stream.readinto(xBuf) fpos+=nb - eol=eol-start_1 - start_1=0 - bp=eol+2 bl=keepLen+nb if nb