Skip to content

Commit

Permalink
fix range calculation in compose_object API (#87)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored May 29, 2024
1 parent 43af364 commit 18c5707
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -968,8 +968,8 @@ impl Client {
etag: resp.etag,
});

offset = start_bytes;
size -= end_bytes - start_bytes;
offset += length;
size -= length;
}
}
}
Expand Down

0 comments on commit 18c5707

Please sign in to comment.