Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not validate checksums for partial responses
Browse files Browse the repository at this point in the history
SimonBohnenQC committed Oct 4, 2022
1 parent 43579c6 commit 5c03176
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions google/_async_resumable_media/requests/download.py
Original file line number Diff line number Diff line change
@@ -90,7 +90,8 @@ async def _write_to_stream(self, response):
self._stream.write(chunk)
local_checksum_object.update(chunk)

if expected_checksum is not None:
# Don't validate the checksum for partial responses.
if expected_checksum is not None and response.status != 206:
actual_checksum = sync_helpers.prepare_checksum_digest(
checksum_object.digest()
)
@@ -213,7 +214,8 @@ async def _write_to_stream(self, response):
self._stream.write(chunk)
checksum_object.update(chunk)

if expected_checksum is not None:
# Don't validate the checksum for partial responses.
if expected_checksum is not None and response.status != 206:
actual_checksum = sync_helpers.prepare_checksum_digest(
checksum_object.digest()
)
6 changes: 4 additions & 2 deletions google/resumable_media/requests/download.py
Original file line number Diff line number Diff line change
@@ -124,7 +124,8 @@ def _write_to_stream(self, response):
self._bytes_downloaded += len(chunk)
local_checksum_object.update(chunk)

if expected_checksum is not None:
# Don't validate the checksum for partial responses.
if expected_checksum is not None and response.status_code != 206:
actual_checksum = _helpers.prepare_checksum_digest(checksum_object.digest())
if actual_checksum != expected_checksum:
msg = _CHECKSUM_MISMATCH.format(
@@ -308,7 +309,8 @@ def _write_to_stream(self, response):
checksum_object.update(chunk)
response._content_consumed = True

if expected_checksum is not None:
# Don't validate the checksum for partial responses.
if expected_checksum is not None and response.status_code != 206:
actual_checksum = _helpers.prepare_checksum_digest(checksum_object.digest())

if actual_checksum != expected_checksum:

0 comments on commit 5c03176

Please sign in to comment.