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.
This commit is contained in:
parent
904859d676
commit
d4d68f57e5
2 changed files with 125 additions and 20 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue