Use multipart copy in copyObject smaller files: (#23)

This change makes copyObject use multipart strategy when the object to
be created has a size larger than 64 MiB. Previously this strategy was
used when the object is larger than 5GiB only.
This commit is contained in:
Aditya Manthramurthy 2017-03-03 16:50:59 +05:30 committed by Krishnan Parthasarathi
parent de97837020
commit c30d4b2ce5
2 changed files with 4 additions and 2 deletions

View File

@ -47,6 +47,7 @@ module Network.Minio
, ObjectPartInfo(..)
, UploadId
, ObjectData(..)
, CopyPartSource(..)
-- * Bucket Operations
----------------------

View File

@ -229,15 +229,16 @@ copyObjectInternal b' o cps = do
snd range >= fromIntegral srcSize]) $
throwM $ ValidationError $ MErrVInvalidSrcObjByteRange range
-- 1. If sz > 5gb use multipart copy
-- 1. If sz > 64MiB (minPartSize) use multipart copy, OR
-- 2. If startOffset /= 0 use multipart copy
let destSize = (\(a, b) -> b - a + 1 ) $
maybe (0, srcSize - 1) identity $ cpSourceRange cps
startOffset = maybe 0 fst $ cpSourceRange cps
endOffset = maybe (srcSize - 1) snd $ cpSourceRange cps
if destSize > maxObjectPartSize || (endOffset - startOffset + 1 /= srcSize)
if destSize > minPartSize || (endOffset - startOffset + 1 /= srcSize)
then multiPartCopyObject b' o cps srcSize
else fst <$> copyObjectSingle b' o cps{cpSourceRange = Nothing} []
where