From 28ea77f8e915ef86f6fe9ec690621d41e83b8300 Mon Sep 17 00:00:00 2001 From: Jiri Suchan Date: Wed, 22 Nov 2023 15:17:43 +0700 Subject: [PATCH 1/3] fix: provide error message for mismatching upload size options --- b2sdk/transfer/emerge/planner/planner.py | 9 ++++++++- changelog.d/b2cli934.changed.md | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelog.d/b2cli934.changed.md diff --git a/b2sdk/transfer/emerge/planner/planner.py b/b2sdk/transfer/emerge/planner/planner.py index 243b07878..281d13d81 100644 --- a/b2sdk/transfer/emerge/planner/planner.py +++ b/b2sdk/transfer/emerge/planner/planner.py @@ -94,7 +94,14 @@ def __init__( self.min_part_size = min_part_size or DEFAULT_MIN_PART_SIZE self.recommended_upload_part_size = recommended_upload_part_size or DEFAULT_RECOMMENDED_UPLOAD_PART_SIZE self.max_part_size = max_part_size or DEFAULT_MAX_PART_SIZE - assert self.min_part_size <= self.recommended_upload_part_size <= self.max_part_size + if self.min_part_size > self.recommended_upload_part_size: + raise ValueError( + f"min_part_size value ({self.min_part_size}) exceeding recommended_upload_part_size value ({self.recommended_upload_part_size})" + ) + if self.recommended_upload_part_size > self.max_part_size: + raise ValueError( + f"recommended_upload_part_size value ({self.recommended_upload_part_size}) exceeding max_part_size value ({self.max_part_size})" + ) @classmethod def from_account_info( diff --git a/changelog.d/b2cli934.changed.md b/changelog.d/b2cli934.changed.md new file mode 100644 index 000000000..141e42bf0 --- /dev/null +++ b/changelog.d/b2cli934.changed.md @@ -0,0 +1 @@ +Replace blank `assert` with exception when size values for parts upload are misaligned. From 79abd623fac0b8836161672a876db4f88aec37f0 Mon Sep 17 00:00:00 2001 From: Jiri Suchan Date: Mon, 4 Dec 2023 13:15:08 +0700 Subject: [PATCH 2/3] use proper exception class --- b2sdk/transfer/emerge/planner/planner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/b2sdk/transfer/emerge/planner/planner.py b/b2sdk/transfer/emerge/planner/planner.py index 281d13d81..3e992938d 100644 --- a/b2sdk/transfer/emerge/planner/planner.py +++ b/b2sdk/transfer/emerge/planner/planner.py @@ -15,6 +15,7 @@ from collections import deque from math import ceil +from b2sdk.exception import InvalidUserInput from b2sdk.http_constants import ( DEFAULT_MAX_PART_SIZE, DEFAULT_MIN_PART_SIZE, @@ -95,11 +96,11 @@ def __init__( self.recommended_upload_part_size = recommended_upload_part_size or DEFAULT_RECOMMENDED_UPLOAD_PART_SIZE self.max_part_size = max_part_size or DEFAULT_MAX_PART_SIZE if self.min_part_size > self.recommended_upload_part_size: - raise ValueError( + raise InvalidUserInput( f"min_part_size value ({self.min_part_size}) exceeding recommended_upload_part_size value ({self.recommended_upload_part_size})" ) if self.recommended_upload_part_size > self.max_part_size: - raise ValueError( + raise InvalidUserInput( f"recommended_upload_part_size value ({self.recommended_upload_part_size}) exceeding max_part_size value ({self.max_part_size})" ) From 020219e819f69594a58d602825bf8677c728e239 Mon Sep 17 00:00:00 2001 From: Jiri Suchan Date: Mon, 4 Dec 2023 14:39:28 +0700 Subject: [PATCH 3/3] fix changelog items prefix --- ...2cli934.changed.md => +upload-check-replace-assert.changed.md} | 0 .../{b2cli958.changed.md => +xdg-config-home-fallback.changed.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{b2cli934.changed.md => +upload-check-replace-assert.changed.md} (100%) rename changelog.d/{b2cli958.changed.md => +xdg-config-home-fallback.changed.md} (100%) diff --git a/changelog.d/b2cli934.changed.md b/changelog.d/+upload-check-replace-assert.changed.md similarity index 100% rename from changelog.d/b2cli934.changed.md rename to changelog.d/+upload-check-replace-assert.changed.md diff --git a/changelog.d/b2cli958.changed.md b/changelog.d/+xdg-config-home-fallback.changed.md similarity index 100% rename from changelog.d/b2cli958.changed.md rename to changelog.d/+xdg-config-home-fallback.changed.md