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
|
||||
go iv n
|
||||
| n == 0 = return ()
|
||||
| n > fromIntegral defaultChunkSize = do
|
||||
updateIncremental iv =<< S.hGet h defaultChunkSize
|
||||
go iv (n - fromIntegral defaultChunkSize)
|
||||
| otherwise =
|
||||
updateIncremental iv =<< S.hGet h (fromIntegral n)
|
||||
| otherwise = do
|
||||
let c = if n > fromIntegral defaultChunkSize
|
||||
then defaultChunkSize
|
||||
else 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
|
||||
v <- runner getb
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue