summaryrefslogtreecommitdiff
path: root/Remote/Helper/Chunked/Legacy.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-26 20:11:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-26 20:11:41 -0400
commit03957e64cbfe4710615dfd774b05b6182cba5ee7 (patch)
tree5a74e63eee2c9805e614e92f524d5a4d6fd1f7ca /Remote/Helper/Chunked/Legacy.hs
parentbce4a15b98f4d899fc7fe6436cd229240b845392 (diff)
finish up basic chunked remote groundwork
Chunk retrieval and reassembly, removal, and checking if all necessary chunks are present. This commit was sponsored by Damien Raude-Morvan.
Diffstat (limited to 'Remote/Helper/Chunked/Legacy.hs')
-rw-r--r--Remote/Helper/Chunked/Legacy.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Remote/Helper/Chunked/Legacy.hs b/Remote/Helper/Chunked/Legacy.hs
index 1ec0eb68f..e435851db 100644
--- a/Remote/Helper/Chunked/Legacy.hs
+++ b/Remote/Helper/Chunked/Legacy.hs
@@ -9,6 +9,7 @@ module Remote.Helper.Chunked.Legacy where
import Common.Annex
import Remote.Helper.Chunked
+import Utility.Metered
import qualified Data.ByteString.Lazy as L
import qualified Control.Exception as E
@@ -114,3 +115,12 @@ storeChunked chunksize dests storer content = either onerr return
let (chunk, b') = L.splitAt sz b
storer d chunk
storechunks sz (d:useddests) ds b'
+
+{- Writes a series of chunks to a file. The feeder is called to get
+ - each chunk.
+ -}
+meteredWriteFileChunks :: MeterUpdate -> FilePath -> [v] -> (v -> IO L.ByteString) -> IO ()
+meteredWriteFileChunks meterupdate dest chunks feeder =
+ withBinaryFile dest WriteMode $ \h ->
+ forM_ chunks $
+ meteredWrite meterupdate h <=< feeder