From 18c5707a4a964a5d70ceb0633c74f1e98418f0c2 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Thu, 30 May 2024 01:22:33 +0530 Subject: [PATCH] fix range calculation in compose_object API (#87) Signed-off-by: Bala.FA --- src/s3/client.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/s3/client.rs b/src/s3/client.rs index e707fb7e..efc4d638 100644 --- a/src/s3/client.rs +++ b/src/s3/client.rs @@ -941,16 +941,16 @@ impl Client { while size > 0 { part_number += 1; - let start_bytes = offset; - let mut end_bytes = start_bytes + MAX_PART_SIZE; - if size < MAX_PART_SIZE { - end_bytes = start_bytes + size; + let mut length = size; + if length > MAX_PART_SIZE { + length = MAX_PART_SIZE; } + let end_bytes = offset + length - 1; let mut headers_copy = headers.clone(); headers_copy.insert( String::from("x-amz-copy-source-range"), - format!("bytes={}-{}", start_bytes, end_bytes), + format!("bytes={}-{}", offset, end_bytes), ); let mut upc_args = UploadPartCopyArgs::new( @@ -968,8 +968,8 @@ impl Client { etag: resp.etag, }); - offset = start_bytes; - size -= end_bytes - start_bytes; + offset += length; + size -= length; } } }