mirror of
https://github.com/pgsty/minio.git
synced 2026-10-18 07:26:10 +03:00
fix: name the checksum algorithm in PutObject/UploadPart mismatch errors
hash.ChecksumMismatch now carries the requested algorithm (CRC32, CRC32C, SHA1, SHA256, CRC64NVME), and toAPIError renders it S3-style: The CRC32 you specified did not match the calculated checksum. instead of the generic "The provided 'x-amz-checksum' header does not match what was computed.", for all four mismatch construction sites (streaming reader, trailing-checksum decode, and both Checksum.Matches paths). Mirrors the wording already shipped for CompleteMultipartUpload in #225. Fixes #226
This commit is contained in:
@@ -584,15 +584,17 @@ func (c Checksum) Matches(content []byte, parts int) error {
|
||||
sum := hasher.Sum(nil)
|
||||
if c.WantParts > 0 && c.WantParts != parts {
|
||||
return ChecksumMismatch{
|
||||
Want: fmt.Sprintf("%s-%d", c.Encoded, c.WantParts),
|
||||
Got: fmt.Sprintf("%s-%d", base64.StdEncoding.EncodeToString(sum), parts),
|
||||
Algorithm: c.Type.String(),
|
||||
Want: fmt.Sprintf("%s-%d", c.Encoded, c.WantParts),
|
||||
Got: fmt.Sprintf("%s-%d", base64.StdEncoding.EncodeToString(sum), parts),
|
||||
}
|
||||
}
|
||||
|
||||
if !bytes.Equal(sum, c.Raw) {
|
||||
return ChecksumMismatch{
|
||||
Want: c.Encoded,
|
||||
Got: base64.StdEncoding.EncodeToString(sum),
|
||||
Algorithm: c.Type.String(),
|
||||
Want: c.Encoded,
|
||||
Got: base64.StdEncoding.EncodeToString(sum),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user