From 130e593280e9f0cd71bbc075250f148dae41fdb7 Mon Sep 17 00:00:00 2001 From: Jiri Suchan Date: Wed, 22 Nov 2023 15:17:43 +0700 Subject: [PATCH] fix: provide error message for mismatching upload size options --- b2sdk/transfer/emerge/planner/planner.py | 7 ++++++- changelog.d/b2cli934.changed.md | 1 + 2 files changed, 7 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..72fffaeb1 100644 --- a/b2sdk/transfer/emerge/planner/planner.py +++ b/b2sdk/transfer/emerge/planner/planner.py @@ -94,7 +94,12 @@ 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("min_part_size value (%s) exceeding recommended_upload_part_size value (%s)" % ( + self.min_part_size, self.recommended_upload_part_size)) + if self.recommended_upload_part_size > self.max_part_size: + raise ValueError("recommended_upload_part_size value (%s) exceeding max_part_size value (%s)" % ( + self.recommended_upload_part_size, 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.