Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide error message for misaligned part sizes #446

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/b2cli934.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.