mirror of https://github.com/scrapy/scrapy.git
base64-decode GCS checksums (#5891)
This commit is contained in:
parent
283e1eb302
commit
d47c732ae9
|
|
@ -3,6 +3,7 @@ Files Pipeline
|
|||
|
||||
See documentation in topics/media-pipeline.rst
|
||||
"""
|
||||
import base64
|
||||
import functools
|
||||
import hashlib
|
||||
import logging
|
||||
|
|
@ -228,7 +229,7 @@ class GCSFilesStore:
|
|||
def stat_file(self, path, info):
|
||||
def _onsuccess(blob):
|
||||
if blob:
|
||||
checksum = blob.md5_hash
|
||||
checksum = base64.b64decode(blob.md5_hash).hex()
|
||||
last_modified = time.mktime(blob.updated.timetuple())
|
||||
return {"checksum": checksum, "last_modified": last_modified}
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ class TestGCSFilesStore(unittest.TestCase):
|
|||
s = yield store.stat_file(path, info=None)
|
||||
self.assertIn("last_modified", s)
|
||||
self.assertIn("checksum", s)
|
||||
self.assertEqual(s["checksum"], "zc2oVgXkbQr2EQdSdw3OPA==")
|
||||
self.assertEqual(s["checksum"], "cdcda85605e46d0af6110752770dce3c")
|
||||
u = urlparse(uri)
|
||||
content, acl, blob = get_gcs_content_and_delete(u.hostname, u.path[1:] + path)
|
||||
self.assertEqual(content, data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue