Skip to content

Commit 0352bb3

Browse files
authored
fix range calculation in ComposeObject API (#140)
Signed-off-by: Bala.FA <bala@minio.io>
1 parent e9e63da commit 0352bb3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/client.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,14 @@ ComposeObjectResponse Client::ComposeObject(ComposeObjectArgs args,
326326
while (size > 0) {
327327
part_number++;
328328

329-
size_t start_bytes = offset;
330-
size_t end_bytes = start_bytes + utils::kMaxPartSize;
331-
if (size < utils::kMaxPartSize) end_bytes = start_bytes + size;
329+
size_t length = size;
330+
if (length > utils::kMaxPartSize) length = utils::kMaxPartSize;
331+
size_t end_bytes = offset + length - 1;
332332

333333
utils::Multimap headerscopy;
334334
headerscopy.AddAll(headers);
335335
headerscopy.Add("x-amz-copy-source-range",
336-
"bytes=" + std::to_string(start_bytes) + "-" +
336+
"bytes=" + std::to_string(offset) + "-" +
337337
std::to_string(end_bytes));
338338

339339
UploadPartCopyArgs upc_args;
@@ -350,8 +350,8 @@ ComposeObjectResponse Client::ComposeObject(ComposeObjectArgs args,
350350
}
351351
parts.push_back(Part(part_number, std::move(resp.etag)));
352352
}
353-
offset = start_bytes;
354-
size -= (end_bytes - start_bytes);
353+
offset += length;
354+
size -= length;
355355
}
356356
}
357357
}

0 commit comments

Comments
 (0)