Fix block id length upto 8bytes only for azure gateway. (#5731)

This PR also reverts commit 2f9354b17e
to bring back 8 byte block id requirement for azure gateway.
This commit is contained in:
Harshavardhana 2018-03-29 09:54:47 -07:00 committed by kannappanr
parent 228c8f05f4
commit 35b3913d22
1 changed files with 12 additions and 4 deletions

View File

@ -19,6 +19,7 @@ package azure
import (
"bytes"
"context"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"encoding/json"
@ -38,7 +39,6 @@ import (
"github.com/minio/minio/pkg/errors"
"github.com/minio/minio/pkg/hash"
sha256 "github.com/minio/sha256-simd"
"github.com/skyrings/skyring-common/tools/uuid"
minio "github.com/minio/minio/cmd"
)
@ -354,12 +354,20 @@ func azureToObjectError(err error, params ...string) error {
}
// mustGetAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value.
// this 8 byte restriction is needed because Azure block id has a restriction of length
// upto 8 bytes.
func mustGetAzureUploadID() string {
uuid, err := uuid.New()
var id [8]byte
n, err := io.ReadFull(rand.Reader, id[:])
if err != nil {
panic(err)
panic(fmt.Errorf("unable to generate upload ID for azure. %s", err))
}
return fmt.Sprintf("%x", uuid[:])
if n != len(id) {
panic(fmt.Errorf("insufficient random data (expected: %d, read: %d)", len(id), n))
}
return hex.EncodeToString(id[:])
}
// checkAzureUploadID - returns error in case of given string is upload ID.