Merge pull request #589 from harshavardhana/pr_out_use_convenience_functions_for_url_values_over_looping_through_keys_fix_a_bug_in_listobjectparts_

master
Harshavardhana 10 years ago
commit 01c1bd6fc5
  1. 11
      pkg/api/api_object_handlers.go
  2. 35
      pkg/api/resources.go
  3. 5
      pkg/storage/drivers/memory/memory.go

@ -305,15 +305,8 @@ func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Re
bucket := vars["bucket"] bucket := vars["bucket"]
object := vars["object"] object := vars["object"]
var uploadID, partIDString string uploadID := req.URL.Query().Get("uploadId")
for key, value := range req.URL.Query() { partIDString := req.URL.Query().Get("partNumber")
switch true {
case key == "uploadId":
uploadID = value[0]
case key == "partNumber":
partIDString = value[0]
}
}
partID, err := strconv.Atoi(partIDString) partID, err := strconv.Atoi(partIDString)
if err != nil { if err != nil {

@ -25,37 +25,20 @@ import (
// parse bucket url queries // parse bucket url queries
func getBucketResources(values url.Values) (v drivers.BucketResourcesMetadata) { func getBucketResources(values url.Values) (v drivers.BucketResourcesMetadata) {
for key, value := range values { v.Prefix = values.Get("prefix")
switch true { v.Marker = values.Get("marker")
case key == "prefix": v.Maxkeys, _ = strconv.Atoi(values.Get("max-keys"))
v.Prefix = value[0] v.Delimiter = values.Get("delimiter")
case key == "marker": v.EncodingType = values.Get("encoding-type")
v.Marker = value[0]
case key == "max-keys":
v.Maxkeys, _ = strconv.Atoi(value[0])
case key == "delimiter":
v.Delimiter = value[0]
case key == "encoding-type":
v.EncodingType = value[0]
}
}
return return
} }
// parse object url queries // parse object url queries
func getObjectResources(values url.Values) (v drivers.ObjectResourcesMetadata) { func getObjectResources(values url.Values) (v drivers.ObjectResourcesMetadata) {
for key, value := range values { v.UploadID = values.Get("uploadId")
switch true { v.PartNumberMarker, _ = strconv.Atoi(values.Get("part-number-marker"))
case key == "uploadId": v.MaxParts, _ = strconv.Atoi(values.Get("max-parts"))
v.UploadID = value[0] v.EncodingType = values.Get("encoding-type")
case key == "part-number-marker":
v.PartNumberMarker, _ = strconv.Atoi(value[0])
case key == "max-parts":
v.MaxParts, _ = strconv.Atoi(value[0])
case key == "encoding-type":
v.EncodingType = value[0]
}
}
return return
} }

@ -299,7 +299,7 @@ func (memory *memoryDriver) createObject(bucket, key, contentType, expectedMD5Su
memory.lock.Lock() memory.lock.Lock()
memoryObject := make(map[string]drivers.ObjectMetadata) memoryObject := make(map[string]drivers.ObjectMetadata)
switch { switch {
case len(memory.storedBuckets[bucket].objectMetadata) == 0: case len(storedBucket.objectMetadata) == 0:
storedBucket.objectMetadata = memoryObject storedBucket.objectMetadata = memoryObject
storedBucket.objectMetadata[objectKey] = newObject storedBucket.objectMetadata[objectKey] = newObject
default: default:
@ -591,6 +591,7 @@ func (memory *memoryDriver) CreateObjectPart(bucket, key, uploadID string, partI
multiPartSession := storedBucket.multiPartSession[key] multiPartSession := storedBucket.multiPartSession[key]
multiPartSession.totalParts++ multiPartSession.totalParts++
storedBucket.multiPartSession[key] = multiPartSession storedBucket.multiPartSession[key] = multiPartSession
return etag, nil return etag, nil
} }
@ -715,7 +716,7 @@ func (memory *memoryDriver) ListObjectParts(bucket, key string, resources driver
objectResourcesMetadata.NextPartNumberMarker = i objectResourcesMetadata.NextPartNumberMarker = i
return objectResourcesMetadata, nil return objectResourcesMetadata, nil
} }
object, ok := storedBucket.objectMetadata[resources.Bucket+"/"+getMultipartKey(resources.Key, resources.UploadID, i)] object, ok := storedBucket.objectMetadata[bucket+"/"+getMultipartKey(key, resources.UploadID, i)]
if !ok { if !ok {
return drivers.ObjectResourcesMetadata{}, iodine.New(errors.New("missing part: "+strconv.Itoa(i)), nil) return drivers.ObjectResourcesMetadata{}, iodine.New(errors.New("missing part: "+strconv.Itoa(i)), nil)
} }

Loading…
Cancel
Save