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:
Bala FA
2017-10-26 10:17:07 -07:00
committed by Dee Koder
parent d23ded0d83
commit bc8b936d4b
6 changed files with 52 additions and 36 deletions

View File

@@ -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
}