From dbde61e4b425930d1d3041185b3b3ca552cd4634 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Tue, 30 Apr 2024 22:37:27 +0530 Subject: [PATCH] fix range calculation in compose_object API (#1416) Signed-off-by: Bala.FA --- minio/api.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/minio/api.py b/minio/api.py index 6282f21e..56af0578 100644 --- a/minio/api.py +++ b/minio/api.py @@ -1601,13 +1601,11 @@ def compose_object( continue while size > 0: part_number += 1 - start_bytes = offset - end_bytes = start_bytes + MAX_PART_SIZE - if size < MAX_PART_SIZE: - end_bytes = start_bytes + size + length = size if size < MAX_PART_SIZE else MAX_PART_SIZE + end_bytes = offset + length - 1 headers_copy = headers.copy() headers_copy["x-amz-copy-source-range"] = ( - f"bytes={start_bytes}-{end_bytes}" + f"bytes={offset}-{end_bytes}" ) etag, _ = self._upload_part_copy( bucket_name, @@ -1617,8 +1615,8 @@ def compose_object( headers_copy, ) total_parts.append(Part(part_number, etag)) - offset = start_bytes - size -= end_bytes - start_bytes + offset += length + size -= length result = self._complete_multipart_upload( bucket_name, object_name, upload_id, total_parts, )