fix slowloris timeout in hashing resume of download of large file

Hash the data that is already present in the file before connecting to
the http server.
This commit is contained in:
Joey Hess 2024-07-24 11:03:59 -04:00
parent 0594338a78
commit 10f2c23fd7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 33 additions and 36 deletions

View file

@ -234,16 +234,12 @@ resumeVerifyFromOffset
-> IO MeterUpdate
resumeVerifyFromOffset o incrementalverifier meterupdate h
| o /= 0 = do
p' <- case incrementalverifier of
Just iv -> do
go iv o
return offsetmeterupdate
_ -> return offsetmeterupdate
maybe noop (`go` o) incrementalverifier
-- Make sure the handle is seeked to the offset.
-- (Reading the file probably left it there
-- when that was done, but let's be sure.)
hSeek h AbsoluteSeek o
return p'
return offsetmeterupdate
| otherwise = return meterupdate
where
offsetmeterupdate = offsetMeterUpdate meterupdate (toBytesProcessed o)