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:
parent
de97837020
commit
c30d4b2ce5
@ -47,6 +47,7 @@ module Network.Minio
|
|||||||
, ObjectPartInfo(..)
|
, ObjectPartInfo(..)
|
||||||
, UploadId
|
, UploadId
|
||||||
, ObjectData(..)
|
, ObjectData(..)
|
||||||
|
, CopyPartSource(..)
|
||||||
|
|
||||||
-- * Bucket Operations
|
-- * Bucket Operations
|
||||||
----------------------
|
----------------------
|
||||||
|
|||||||
@ -229,15 +229,16 @@ copyObjectInternal b' o cps = do
|
|||||||
snd range >= fromIntegral srcSize]) $
|
snd range >= fromIntegral srcSize]) $
|
||||||
throwM $ ValidationError $ MErrVInvalidSrcObjByteRange range
|
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
|
-- 2. If startOffset /= 0 use multipart copy
|
||||||
let destSize = (\(a, b) -> b - a + 1 ) $
|
let destSize = (\(a, b) -> b - a + 1 ) $
|
||||||
maybe (0, srcSize - 1) identity $ cpSourceRange cps
|
maybe (0, srcSize - 1) identity $ cpSourceRange cps
|
||||||
startOffset = maybe 0 fst $ cpSourceRange cps
|
startOffset = maybe 0 fst $ cpSourceRange cps
|
||||||
endOffset = maybe (srcSize - 1) snd $ 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
|
then multiPartCopyObject b' o cps srcSize
|
||||||
|
|
||||||
else fst <$> copyObjectSingle b' o cps{cpSourceRange = Nothing} []
|
else fst <$> copyObjectSingle b' o cps{cpSourceRange = Nothing} []
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user