From c0985e93b73f1a448d9072272e48622b7c51c5f8 Mon Sep 17 00:00:00 2001 From: Derek Battams Date: Fri, 6 May 2022 15:26:05 -0400 Subject: [PATCH] azureblob: use chunksize lib to determine chunksize dynamically --- backend/azureblob/azureblob.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 880d3eefb..f03ff72ef 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -26,6 +26,7 @@ import ( "github.com/Azure/azure-storage-blob-go/azblob" "github.com/Azure/go-autorest/autorest/adal" "github.com/rclone/rclone/fs" + "github.com/rclone/rclone/fs/chunksize" "github.com/rclone/rclone/fs/config" "github.com/rclone/rclone/fs/config/configmap" "github.com/rclone/rclone/fs/config/configstruct" @@ -1690,25 +1691,17 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op } } - // calculate size of parts/blocks - partSize := int(o.fs.opt.ChunkSize) - uploadParts := int64(maxUploadParts) if uploadParts < 1 { uploadParts = 1 } else if uploadParts > maxUploadParts { uploadParts = maxUploadParts } - - // Adjust partSize until the number of parts/blocks is small enough. - if o.size/int64(partSize) >= uploadParts { - // Calculate partition size rounded up to the nearest MiB - partSize = int((((o.size / uploadParts) >> 20) + 1) << 20) - fs.Debugf(o, "Adjust partSize to %q", partSize) - } + // calculate size of parts/blocks + partSize := chunksize.Calculator(o, int(uploadParts), o.fs.opt.ChunkSize) putBlobOptions := azblob.UploadStreamToBlockBlobOptions{ - BufferSize: partSize, + BufferSize: int(partSize), MaxBuffers: o.fs.opt.UploadConcurrency, Metadata: o.meta, BlobHTTPHeaders: httpHeaders,