From a5385e7a86cd2d3d4405da6990014c7af2aa70f4 Mon Sep 17 00:00:00 2001 From: Sean Wallace Date: Thu, 2 Jul 2020 11:51:39 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Anton Agestam --- collectfast/strategies/boto3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/collectfast/strategies/boto3.py b/collectfast/strategies/boto3.py index 2853c03..9d9a74f 100644 --- a/collectfast/strategies/boto3.py +++ b/collectfast/strategies/boto3.py @@ -38,13 +38,13 @@ def get_local_multipart_hash( self, path: str, local_storage: Storage, chunk_size: int ) -> str: """Calculate multipart hash using a given chunk size.""" - md5s = [] + chunk_hashes = [] with local_storage.open(path, "rb") as f: func: Callable[[], Any] = lambda: f.read(chunk_size) for data in iter(func, b""): md5s.append(hashlib.md5(data).digest()) - m = hashlib.md5(b"".join(md5s)) - return "{}-{}".format(m.hexdigest(), len(md5s)) + summed_hash = hashlib.md5(b"".join(chunk_hashes)).hexdigest() + return f"{summed_hash}-{len(chunk_hashes)}" @lru_cache(maxsize=None) def get_local_file_hash(