-
Notifications
You must be signed in to change notification settings - Fork 155
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
Feat: Add "auto" checksum option and make default #1383
Conversation
7c76ff3
to
a82d9b8
Compare
a82d9b8
to
25e1109
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding clear documentation too! Just a question on adding a parametrized checksum "auto" to the system test.
downloads and None for most uploads. Note that ranged downloads ("start" or | ||
"end" set) still do not support any checksumming, and some features in | ||
`transfer_manager.py` still support crc32c only. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this! This will make 3.0 release notes really clear
if self.checksum == "auto": | ||
self.checksum = ( | ||
"crc32c" if _helpers._is_crc32c_available_and_fast() else "md5" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this is handled in the constructor 🎉
@@ -191,7 +191,7 @@ def test_constructor_defaults(self): | |||
upload = _upload.MultipartUpload(MULTIPART_URL) | |||
assert upload.upload_url == MULTIPART_URL | |||
assert upload._headers == {} | |||
assert upload._checksum_type is None | |||
assert upload._checksum_type == "crc32c" # converted from "auto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 😄
@@ -62,7 +64,7 @@ class CorruptingAuthorizedSession(tr_requests.AuthorizedSession): | |||
""" | |||
|
|||
EMPTY_MD5 = base64.b64encode(hashlib.md5(b"").digest()).decode("utf-8") | |||
crc32c = _helpers._get_crc32c_object() | |||
crc32c = google_crc32c.Checksum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For system tests, maybe we can add a parametrized checksum "auto" here?
python-storage/tests/resumable_media/system/requests/test_download.py
Lines 272 to 273 in d17a15d
@pytest.mark.parametrize("checksum", ["md5", "crc32c", None]) | |
def test_download_full(self, add_files, authorized_transport, checksum): |
Can do the same for an upload integration test here as well
python-storage/tests/resumable_media/system/requests/test_upload.py
Lines 234 to 235 in d17a15d
@pytest.mark.parametrize("checksum", ["md5", "crc32c", None]) | |
def test_multipart_upload(authorized_transport, bucket, cleanup, checksum): |
b2bb316
to
c4201c6
Compare
No description provided.