fix: multipart upload checksum validation (#712)

* fix multipart upload checksum
This commit is contained in:
weisd
2025-10-24 18:23:32 +08:00
committed by GitHub
parent c5264f9703
commit 6a59c0a474
5 changed files with 190 additions and 70 deletions
+6
View File
@@ -78,6 +78,12 @@ impl ChecksumType {
(self.0 & t.0) == t.0
}
/// Merge another checksum type into this one
pub fn merge(&mut self, other: ChecksumType) -> &mut Self {
self.0 |= other.0;
self
}
/// Get the base checksum type (without flags)
pub fn base(self) -> ChecksumType {
ChecksumType(self.0 & Self::BASE_TYPE_MASK)
+6 -3
View File
@@ -331,6 +331,8 @@ impl HashReader {
} else {
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "Invalid checksum type"));
}
tracing::debug!("add_non_trailing_checksum checksum={checksum:?}");
}
Ok(())
}
@@ -359,9 +361,10 @@ impl HashReader {
if checksum.checksum_type.trailing() {
if let Some(trailer) = self.trailer_s3s.as_ref() {
if let Some(Some(checksum_str)) = trailer.read(|headers| {
headers
.get(checksum.checksum_type.to_string())
.and_then(|value| value.to_str().ok().map(|s| s.to_string()))
checksum
.checksum_type
.key()
.and_then(|key| headers.get(key).and_then(|value| value.to_str().ok().map(|s| s.to_string())))
}) {
map.insert(checksum.checksum_type.to_string(), checksum_str);
}