mirror of
https://github.com/minio/minio.git
synced 2025-11-25 12:06:10 -05:00
fix: invalid checksum on site replication with conforming checksum types (#21535)
This commit is contained in:
@@ -145,6 +145,26 @@ func (c ChecksumType) IsSet() bool {
|
||||
return !c.Is(ChecksumInvalid) && !c.Base().Is(ChecksumNone)
|
||||
}
|
||||
|
||||
// ChecksumStringToType is like NewChecksumType but without the `mode`
|
||||
func ChecksumStringToType(alg string) ChecksumType {
|
||||
switch strings.ToUpper(alg) {
|
||||
case "CRC32":
|
||||
return ChecksumCRC32
|
||||
case "CRC32C":
|
||||
return ChecksumCRC32C
|
||||
case "SHA1":
|
||||
return ChecksumSHA1
|
||||
case "SHA256":
|
||||
return ChecksumSHA256
|
||||
case "CRC64NVME":
|
||||
// AWS seems to ignore full value, and just assume it.
|
||||
return ChecksumCRC64NVME
|
||||
case "":
|
||||
return ChecksumNone
|
||||
}
|
||||
return ChecksumInvalid
|
||||
}
|
||||
|
||||
// NewChecksumType returns a checksum type based on the algorithm string and obj type.
|
||||
func NewChecksumType(alg, objType string) ChecksumType {
|
||||
full := ChecksumFullObject
|
||||
@@ -240,6 +260,12 @@ func (c ChecksumType) ObjType() string {
|
||||
if c.FullObjectRequested() {
|
||||
return xhttp.AmzChecksumTypeFullObject
|
||||
}
|
||||
if c.IsMultipartComposite() {
|
||||
return xhttp.AmzChecksumTypeComposite
|
||||
}
|
||||
if !c.Is(ChecksumMultipart) {
|
||||
return xhttp.AmzChecksumTypeFullObject
|
||||
}
|
||||
if c.IsSet() {
|
||||
return xhttp.AmzChecksumTypeComposite
|
||||
}
|
||||
@@ -340,12 +366,8 @@ func ReadCheckSums(b []byte, part int) (cs map[string]string, isMP bool) {
|
||||
}
|
||||
if cs != "" {
|
||||
res[typ.String()] = cs
|
||||
res[xhttp.AmzChecksumType] = typ.ObjType()
|
||||
if !typ.Is(ChecksumMultipart) {
|
||||
// Single part PUTs are always FULL_OBJECT checksum
|
||||
// Refer https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
||||
// **For PutObject uploads, the checksum type is always FULL_OBJECT.**
|
||||
res[xhttp.AmzChecksumType] = ChecksumFullObject.ObjType()
|
||||
if ckType := typ.ObjType(); ckType != "" {
|
||||
res[xhttp.AmzChecksumType] = ckType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user