Skip to content

Commit

Permalink
Fix for issue #672 (#775)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Martin Durant <[email protected]>
  • Loading branch information
coolacid and martindurant authored Sep 16, 2023
1 parent b1d378c commit d6e3938
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,10 @@ def _upload_chunk(self, final=False):
Key=key,
)

self.parts.append({"PartNumber": part, "ETag": out["ETag"]})
part_header = {"PartNumber": part, "ETag": out["ETag"]}
if "ChecksumSHA256" in out:
part_header["ChecksumSHA256"] = out["ChecksumSHA256"]
self.parts.append(part_header)

if self.autocommit and final:
self.commit()
Expand Down
29 changes: 29 additions & 0 deletions s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,35 @@ def test_checksum(s3):
s3.checksum(path1, refresh=True)


def test_multi_checksum(s3):
# Moto accepts the request to add checksum, and accepts the checksum mode,
# but doesn't actually return the checksum
# So, this is mostly a stub test
file_key = "checksum"
path = test_bucket_name + "/" + file_key
s3 = S3FileSystem(
anon=False,
client_kwargs={"endpoint_url": endpoint_uri},
s3_additional_kwargs={"ChecksumAlgorithm": "SHA256"},
)
with s3.open(
path,
"wb",
blocksize=5 * 2**20,
) as f:
f.write(b"0" * (5 * 2**20 + 1)) # starts multipart and puts first part
f.write(b"data") # any extra data
assert s3.cat(path) == b"0" * (5 * 2**20 + 1) + b"data"
FileHead = sync(
s3.loop,
s3.s3.head_object,
Bucket=test_bucket_name,
Key=file_key,
ChecksumMode="ENABLED",
)
# assert "ChecksumSHA256" in FileHead


test_xattr_sample_metadata = {"testxattr": "1"}


Expand Down

0 comments on commit d6e3938

Please sign in to comment.