Fixing a race in NewMultipartUpload() session for simultaneous requests, observed at play.minio.io

master
Harshavardhana 10 years ago
parent eb34634e81
commit c41ebf7535
  1. 5
      pkg/storage/drivers/memory/memory.go

@ -334,6 +334,7 @@ func (memory *memoryDriver) CreateBucket(bucketName, acl string) error {
}
var newBucket = storedBucket{}
newBucket.objectMetadata = make(map[string]drivers.ObjectMetadata)
newBucket.multiPartSession = make(map[string]multiPartSession)
newBucket.bucketMetadata = drivers.BucketMetadata{}
newBucket.bucketMetadata.Name = bucketName
newBucket.bucketMetadata.Created = time.Now().UTC()
@ -540,13 +541,11 @@ func (memory *memoryDriver) NewMultipartUpload(bucket, key, contentType string)
uploadIDSum := sha512.Sum512(id)
uploadID := base64.URLEncoding.EncodeToString(uploadIDSum[:])[:47]
storedBucket.multiPartSession = make(map[string]multiPartSession)
storedBucket.multiPartSession[key] = multiPartSession{
memory.storedBuckets[bucket].multiPartSession[key] = multiPartSession{
uploadID: uploadID,
initiated: time.Now(),
totalParts: 0,
}
memory.storedBuckets[bucket] = storedBucket
memory.lock.Unlock()
return uploadID, nil

Loading…
Cancel
Save