Skip to content

Commit 95467c2

Browse files
ndokosportante
authored andcommitted
Fix bug when reading a file in chunks
Fix #2034 Commit 8a44178 broke the function calculate_multipart_etag(): it replaced a (working) while-loop that was reading the tarball in chunks with a broken for-loop which read one chunk of the file and then iterated over the bytes of that chunk. We retain the for-loop but fix the iterator to give us back the next chunk each time.
1 parent 8e14bd2 commit 95467c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/pbench/server/s3backup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def calculate_multipart_etag(tb, chunk_size):
306306
md5s = []
307307

308308
with open(tb, "rb") as fp:
309-
for data in fp.read(chunk_size):
309+
for data in iter(lambda: fp.read(chunk_size), b""):
310310
md5s.append(hashlib.md5(data))
311311

312312
if len(md5s) > 1:

0 commit comments

Comments
 (0)