Merge pull request #600 from harshavardhana/pr_out_fixing_a_race_in_newmultipartupload_session_for_simultaneous_requests_observed_at_play_minio_io

This commit is contained in:
Harshavardhana 2015-05-14 19:13:44 -07:00
commit 5751b0bf36
1 changed files with 2 additions and 3 deletions

View File

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