Skip to content

Commit

Permalink
Merge pull request #446 from reef-technologies/yed/gh934-parts-size-c…
Browse files Browse the repository at this point in the history
…omparison

provide error message for misaligned part sizes
  • Loading branch information
mjurbanski-reef authored Dec 4, 2023
2 parents fb8441f + 020219e commit 23d8572
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion b2sdk/transfer/emerge/planner/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -94,7 +95,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 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 InvalidUserInput(
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(
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+upload-check-replace-assert.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace blank `assert` with exception when size values for parts upload are misaligned.
File renamed without changes.

0 comments on commit 23d8572

Please sign in to comment.