From 114ff1769d192bcde8ecbc160083e059f25ee96c Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Wed, 1 May 2024 06:51:06 +0530 Subject: [PATCH] fix range calculation in ComposeObject API Signed-off-by: Bala.FA --- src/client.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client.cc b/src/client.cc index 5673315..94ffd56 100644 --- a/src/client.cc +++ b/src/client.cc @@ -326,14 +326,14 @@ ComposeObjectResponse Client::ComposeObject(ComposeObjectArgs args, while (size > 0) { part_number++; - size_t start_bytes = offset; - size_t end_bytes = start_bytes + utils::kMaxPartSize; - if (size < utils::kMaxPartSize) end_bytes = start_bytes + size; + size_t length = size; + if (length > utils::kMaxPartSize) length = utils::kMaxPartSize; + size_t end_bytes = offset + length - 1; utils::Multimap headerscopy; headerscopy.AddAll(headers); headerscopy.Add("x-amz-copy-source-range", - "bytes=" + std::to_string(start_bytes) + "-" + + "bytes=" + std::to_string(offset) + "-" + std::to_string(end_bytes)); UploadPartCopyArgs upc_args; @@ -350,8 +350,8 @@ ComposeObjectResponse Client::ComposeObject(ComposeObjectArgs args, } parts.push_back(Part(part_number, std::move(resp.etag))); } - offset = start_bytes; - size -= (end_bytes - start_bytes); + offset += length; + size -= length; } } }