mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
convert ETag properly for all gateways (#5099)
Previously ID/ETag from backend service is used as is which causes failure on s3cmd like tools where those tools use ETag as checksum to validate data. This is fixed by prepending "-1". Refer minio/mint#193 minio/mint#201
This commit is contained in:
18
cmd/utils.go
18
cmd/utils.go
@@ -211,3 +211,21 @@ func checkURL(urlStr string) (*url.URL, error) {
|
||||
func UTCNow() time.Time {
|
||||
return time.Now().UTC()
|
||||
}
|
||||
|
||||
// genETag - generate UUID based ETag
|
||||
func genETag() string {
|
||||
return toS3ETag(getMD5Hash([]byte(mustGetUUID())))
|
||||
}
|
||||
|
||||
// toS3ETag - return checksum to ETag
|
||||
func toS3ETag(etag string) string {
|
||||
etag = canonicalizeETag(etag)
|
||||
|
||||
if !strings.HasSuffix(etag, "-1") {
|
||||
// Tools like s3cmd uses ETag as checksum of data to validate.
|
||||
// Append "-1" to indicate ETag is not a checksum.
|
||||
etag += "-1"
|
||||
}
|
||||
|
||||
return etag
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user