WIP 3
This commit is contained in:
parent
d16382e99f
commit
62de9a39bf
1 changed files with 6 additions and 9 deletions
15
Remote/S3.hs
15
Remote/S3.hs
|
@ -26,10 +26,6 @@ import Network.HTTP.Types
|
||||||
import Control.Monad.Trans.Resource
|
import Control.Monad.Trans.Resource
|
||||||
import Control.Monad.Catch
|
import Control.Monad.Catch
|
||||||
import Data.Conduit
|
import Data.Conduit
|
||||||
#if MIN_VERSION_aws(0,10,6)
|
|
||||||
import qualified Data.Conduit.List as CL
|
|
||||||
import qualified Data.Conduit.Binary as CB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
|
@ -188,16 +184,17 @@ store r h = fileStorer $ \k f p -> do
|
||||||
-- Send parts of the file, taking care to stream each part
|
-- Send parts of the file, taking care to stream each part
|
||||||
-- w/o buffering in memory, since the parts can be large.
|
-- w/o buffering in memory, since the parts can be large.
|
||||||
etags <- bracketIO (openBinaryFile f ReadMode) hClose $ \fh -> do
|
etags <- bracketIO (openBinaryFile f ReadMode) hClose $ \fh -> do
|
||||||
let sendparts etags partnum = ifM (hIsEOF fh)
|
let sendparts meter etags partnum = ifM (liftIO $ hIsOpen fh)
|
||||||
( return (reverse etags)
|
( return (reverse etags)
|
||||||
, do
|
, do
|
||||||
b <- liftIO $ hGetUntilMetered fh (< partsz) p
|
b <- liftIO $ hGetUntilMetered fh (< partsz) meter
|
||||||
let body = RequestBodyStream (L.length b) (mkPopper b)
|
let sz = L.length b
|
||||||
|
let body = RequestBodyStream sz (mkPopper b)
|
||||||
S3.UploadPartResponse _ etag <- sendS3Handle h $
|
S3.UploadPartResponse _ etag <- sendS3Handle h $
|
||||||
S3.uploadPart (bucket info) object partnum uploadid body
|
S3.uploadPart (bucket info) object partnum uploadid body
|
||||||
sendparts (etag:etags) (partnum + 1)
|
sendparts (offsetMeterUpdate meter (toBytesProcessed sz)) (etag:etags) (partnum + 1)
|
||||||
)
|
)
|
||||||
sendparts [] 1
|
sendparts p [] 1
|
||||||
|
|
||||||
void $ sendS3Handle h $ S3.postCompleteMultipartUpload
|
void $ sendS3Handle h $ S3.postCompleteMultipartUpload
|
||||||
(bucket info) object uploadid (zip [1..] etags)
|
(bucket info) object uploadid (zip [1..] etags)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue