Skip to content

Commit

Permalink
fix range calculation in ComposeObject API
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana committed May 1, 2024
1 parent c3ce2fa commit 114ff17
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit 114ff17

Please sign in to comment.