Bugfix: totalUnconsumedBytes works properly within withReadableRange blocks

This commit is contained in:
Zahary Karadjov 2020-05-29 16:08:14 +03:00
commit 81c24860e2
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
2 changed files with 13 additions and 2 deletions

View file

@ -282,8 +282,12 @@ func totalUnconsumedBytes*(s: InputStream): Natural =
## buffers and that can be consumed with `read` or `advance`.
let
localRunway = s.span.len
runwayInBuffers = if s.buffers == nil: 0
else: s.buffers.totalBufferedBytes
runwayInBuffers = if s.buffers == nil:
0
elif s.buffers.fauxEofPos != 0:
s.buffers.fauxEofPos - s.spanEndPos
else:
s.buffers.totalBufferedBytes
if localRunway == 0 and runwayInBuffers > 0:
getNewSpan s