From c30d4b2ce599d66fae50a6a0c751cfedc64fa307 Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Fri, 3 Mar 2017 16:50:59 +0530 Subject: [PATCH] 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. --- src/Network/Minio.hs | 1 + src/Network/Minio/PutObject.hs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Network/Minio.hs b/src/Network/Minio.hs index b1f703d..cbfc2da 100644 --- a/src/Network/Minio.hs +++ b/src/Network/Minio.hs @@ -47,6 +47,7 @@ module Network.Minio , ObjectPartInfo(..) , UploadId , ObjectData(..) + , CopyPartSource(..) -- * Bucket Operations ---------------------- diff --git a/src/Network/Minio/PutObject.hs b/src/Network/Minio/PutObject.hs index 38f6434..8339fce 100644 --- a/src/Network/Minio/PutObject.hs +++ b/src/Network/Minio/PutObject.hs @@ -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