incremental verify for webdav special remote

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2021-08-16 16:51:58 -04:00
parent b1622eb932
commit 8613770b06
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 25 additions and 17 deletions

View file

@ -1,6 +1,6 @@
{- helpers for remotes using http
-
- Copyright 2014 Joey Hess <id@joeyh.name>
- Copyright 2014-2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -11,6 +11,7 @@ module Remote.Helper.Http where
import Annex.Common
import Types.StoreRetrieve
import Types.Backend
import Remote.Helper.Special
import Utility.Metered
@ -67,9 +68,9 @@ handlePopper numchunks chunksize meterupdate h sink = do
target = toBytesProcessed (numchunks * fromIntegral chunksize)
-- Reads the http body and stores it to the specified file, updating the
-- meter as it goes.
httpBodyRetriever :: FilePath -> MeterUpdate -> Response BodyReader -> IO ()
httpBodyRetriever dest meterupdate resp
-- meter and incremental verifier as it goes.
httpBodyRetriever :: FilePath -> MeterUpdate -> Maybe IncrementalVerifier -> Response BodyReader -> IO ()
httpBodyRetriever dest meterupdate iv resp
| responseStatus resp /= ok200 = giveup $ show $ responseStatus resp
| otherwise = bracket (openBinaryFile dest WriteMode) hClose (go zeroBytesProcessed)
where
@ -82,4 +83,5 @@ httpBodyRetriever dest meterupdate resp
let sofar' = addBytesProcessed sofar $ S.length b
S.hPut h b
meterupdate sofar'
maybe noop (flip updateIncremental b) iv
go sofar' h