combine 2 checks
This commit is contained in:
parent
0f78f197eb
commit
29871e320c
1 changed files with 15 additions and 15 deletions
30
Remote/S3.hs
30
Remote/S3.hs
|
@ -188,21 +188,21 @@ 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 meter etags partnum = ifM (liftIO $ hIsClosed fh)
|
let sendparts meter etags partnum = do
|
||||||
( return (reverse etags)
|
pos <- liftIO $ hTell fh
|
||||||
, do
|
if pos >= fsz
|
||||||
pos <- liftIO $ hTell fh
|
then return (reverse etags)
|
||||||
-- Calculate size of part that will
|
else do
|
||||||
-- be read.
|
-- Calculate size of part that will
|
||||||
let sz = if fsz - pos < partsz'
|
-- be read.
|
||||||
then fsz - pos
|
let sz = if fsz - pos < partsz'
|
||||||
else partsz'
|
then fsz - pos
|
||||||
b <- liftIO $ hGetUntilMetered fh (< partsz') meter
|
else partsz'
|
||||||
let body = RequestBodyStream (fromIntegral sz) (mkPopper b)
|
b <- liftIO $ hGetUntilMetered fh (< partsz') meter
|
||||||
S3.UploadPartResponse _ etag <- sendS3Handle h $
|
let body = RequestBodyStream (fromIntegral sz) (mkPopper b)
|
||||||
S3.uploadPart (bucket info) object partnum uploadid body
|
S3.UploadPartResponse _ etag <- sendS3Handle h $
|
||||||
sendparts (offsetMeterUpdate meter (toBytesProcessed sz)) (etag:etags) (partnum + 1)
|
S3.uploadPart (bucket info) object partnum uploadid body
|
||||||
)
|
sendparts (offsetMeterUpdate meter (toBytesProcessed sz)) (etag:etags) (partnum + 1)
|
||||||
sendparts p [] 1
|
sendparts p [] 1
|
||||||
|
|
||||||
void $ sendS3Handle h $ S3.postCompleteMultipartUpload
|
void $ sendS3Handle h $ S3.postCompleteMultipartUpload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue