deal with possibility of short read by S.hGet
It may read less than requested, and may yield an empty string if the file was somehow shorter than expected.
This commit is contained in:
parent
62e152f210
commit
94f6210b68
1 changed files with 8 additions and 5 deletions
13
P2P/Annex.hs
13
P2P/Annex.hs
|
@ -172,11 +172,14 @@ runLocal runst runner a = case a of
|
||||||
where
|
where
|
||||||
go iv n
|
go iv n
|
||||||
| n == 0 = return ()
|
| n == 0 = return ()
|
||||||
| n > fromIntegral defaultChunkSize = do
|
| otherwise = do
|
||||||
updateIncremental iv =<< S.hGet h defaultChunkSize
|
let c = if n > fromIntegral defaultChunkSize
|
||||||
go iv (n - fromIntegral defaultChunkSize)
|
then defaultChunkSize
|
||||||
| otherwise =
|
else fromIntegral n
|
||||||
updateIncremental iv =<< S.hGet h (fromIntegral n)
|
b <- S.hGet h c
|
||||||
|
updateIncremental iv b
|
||||||
|
unless (b == S.empty) $
|
||||||
|
go iv (n - fromIntegral (S.length b))
|
||||||
|
|
||||||
storefile dest (Offset o) (Len l) getb incrementalverifier validitycheck p ti = do
|
storefile dest (Offset o) (Len l) getb incrementalverifier validitycheck p ti = do
|
||||||
v <- runner getb
|
v <- runner getb
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue