Skip to content

Commit

Permalink
Do not validate checksums for partial responses
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBohnenQC committed Oct 4, 2022
1 parent 43579c6 commit 91f65af
Show file tree
Hide file tree
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
Expand Up @@ -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()
)
Expand Down Expand Up @@ -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()
)
Expand Down
6 changes: 4 additions & 2 deletions google/resumable_media/requests/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 91f65af

Please sign in to comment.