Merge pull request #746 from harshavardhana/pr_out_writeobject_encoded_data_in_go_routine_fix_another_multipart_issue

WriteObject() encoded data in go routine, fix another multipart issue
master
Harshavardhana 10 years ago
commit fdee527a4d
  1. 15
      pkg/donut/bucket.go
  2. 8
      pkg/donut/multipart.go

@ -417,13 +417,22 @@ func (b bucket) writeObjectData(k, m uint8, writers []io.WriteCloser, objectData
return 0, 0, iodine.New(err, nil)
}
totalLength = totalLength + len(chunk.Data)
encodedBlocks, _ := encoder.Encode(chunk.Data)
encodedBlocks, err := encoder.Encode(chunk.Data)
if err != nil {
return 0, 0, iodine.New(err, nil)
}
sumMD5.Write(chunk.Data)
sum256.Write(chunk.Data)
sum512.Write(chunk.Data)
for blockIndex, block := range encodedBlocks {
_, err := io.Copy(writers[blockIndex], bytes.NewBuffer(block))
if err != nil {
errCh := make(chan error, 1)
go func(writer io.Writer, reader io.Reader) {
defer close(errCh)
_, err := io.Copy(writers[blockIndex], bytes.NewReader(block))
errCh <- err
}(writers[blockIndex], bytes.NewReader(block))
if err := <-errCh; err != nil {
return 0, 0, iodine.New(err, nil)
}
}

@ -281,12 +281,12 @@ func (donut API) CompleteMultipartUpload(bucket, key, uploadID string, data io.R
}
var size int64
var fullObject bytes.Buffer
for i := 1; i <= len(parts.Part); i++ {
recvMD5 := parts.Part[i-1].ETag
object, ok := donut.multiPartObjects[uploadID].Get(parts.Part[i-1].PartNumber)
for i := 0; i < len(parts.Part); i++ {
recvMD5 := parts.Part[i].ETag
object, ok := donut.multiPartObjects[uploadID].Get(parts.Part[i].PartNumber)
if ok == false {
donut.lock.Unlock()
return ObjectMetadata{}, iodine.New(errors.New("missing part: "+strconv.Itoa(i)), nil)
return ObjectMetadata{}, iodine.New(errors.New("missing part: "+strconv.Itoa(parts.Part[i].PartNumber)), nil)
}
size += int64(len(object))
calcMD5Bytes := md5.Sum(object)

Loading…
Cancel
Save