mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Use uuid.New() for uploadID in azure gateway (#5721)
This commit is contained in:
parent
6e9c853312
commit
2f9354b17e
@ -19,7 +19,6 @@ package azure
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -39,6 +38,7 @@ import (
|
|||||||
"github.com/minio/minio/pkg/errors"
|
"github.com/minio/minio/pkg/errors"
|
||||||
"github.com/minio/minio/pkg/hash"
|
"github.com/minio/minio/pkg/hash"
|
||||||
sha256 "github.com/minio/sha256-simd"
|
sha256 "github.com/minio/sha256-simd"
|
||||||
|
"github.com/skyrings/skyring-common/tools/uuid"
|
||||||
|
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
)
|
)
|
||||||
@ -342,17 +342,11 @@ func azureToObjectError(err error, params ...string) error {
|
|||||||
|
|
||||||
// mustGetAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value.
|
// mustGetAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value.
|
||||||
func mustGetAzureUploadID() string {
|
func mustGetAzureUploadID() string {
|
||||||
var id [8]byte
|
uuid, err := uuid.New()
|
||||||
|
|
||||||
n, err := io.ReadFull(rand.Reader, id[:])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("unable to generate upload ID for azure. %s", err))
|
panic(err)
|
||||||
}
|
}
|
||||||
if n != len(id) {
|
return fmt.Sprintf("%x", uuid[:])
|
||||||
panic(fmt.Errorf("insufficient random data (expected: %d, read: %d)", len(id), n))
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%x", id[:])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkAzureUploadID - returns error in case of given string is upload ID.
|
// checkAzureUploadID - returns error in case of given string is upload ID.
|
||||||
@ -695,9 +689,6 @@ func (a *azureObjects) checkUploadIDExists(bucketName, objectName, uploadID stri
|
|||||||
// NewMultipartUpload - Use Azure equivalent CreateBlockBlob.
|
// NewMultipartUpload - Use Azure equivalent CreateBlockBlob.
|
||||||
func (a *azureObjects) NewMultipartUpload(ctx context.Context, bucket, object string, metadata map[string]string) (uploadID string, err error) {
|
func (a *azureObjects) NewMultipartUpload(ctx context.Context, bucket, object string, metadata map[string]string) (uploadID string, err error) {
|
||||||
uploadID = mustGetAzureUploadID()
|
uploadID = mustGetAzureUploadID()
|
||||||
if err = a.checkUploadIDExists(bucket, object, uploadID); err == nil {
|
|
||||||
return "", errors.Trace(fmt.Errorf("Upload ID name collision"))
|
|
||||||
}
|
|
||||||
metadataObject := getAzureMetadataObjectName(object, uploadID)
|
metadataObject := getAzureMetadataObjectName(object, uploadID)
|
||||||
|
|
||||||
var jsonData []byte
|
var jsonData []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user