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

fix: extract hashes correctly during download #238

Merged
merged 8 commits into from Aug 14, 2020
2 changes: 1 addition & 1 deletion google/cloud/storage/blob.py
Expand Up @@ -804,7 +804,7 @@ def _extract_headers_from_download(self, response):

digests = {}
for encoded_digest in x_goog_hash.split(","):
match = re.match(r"(crc32c|md5)=([\w\d]+)==", encoded_digest)
match = re.match(r"(crc32c|md5)=([\w\d]+==)", encoded_digest)
tseaver marked this conversation as resolved.
Show resolved Hide resolved
if match:
method, digest = match.groups()
digests[method] = digest
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_blob.py
Expand Up @@ -1476,8 +1476,8 @@ def test_download_as_string_w_response_headers(self):
self.assertEqual(blob.content_encoding, "gzip")
self.assertEqual(blob.cache_control, "max-age=1337;public")
self.assertEqual(blob.storage_class, "STANDARD")
self.assertEqual(blob.md5_hash, "CS9tHYTtyFntzj7B9nkkJQ")
self.assertEqual(blob.crc32c, "4gcgLQ")
self.assertEqual(blob.md5_hash, "CS9tHYTtyFntzj7B9nkkJQ==")
self.assertEqual(blob.crc32c, "4gcgLQ==")
tseaver marked this conversation as resolved.
Show resolved Hide resolved

def test_download_as_string_w_hash_response_header_none(self):
blob_name = "blob-name"
Expand Down