mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
WriteObject() encoded data in go routine, fix another multipart issue
This commit is contained in:
parent
70e56dc594
commit
634f70f3b0
@ -417,13 +417,22 @@ func (b bucket) writeObjectData(k, m uint8, writers []io.WriteCloser, objectData
|
|||||||
return 0, 0, iodine.New(err, nil)
|
return 0, 0, iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
totalLength = totalLength + len(chunk.Data)
|
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)
|
sumMD5.Write(chunk.Data)
|
||||||
sum256.Write(chunk.Data)
|
sum256.Write(chunk.Data)
|
||||||
sum512.Write(chunk.Data)
|
sum512.Write(chunk.Data)
|
||||||
for blockIndex, block := range encodedBlocks {
|
for blockIndex, block := range encodedBlocks {
|
||||||
_, err := io.Copy(writers[blockIndex], bytes.NewBuffer(block))
|
errCh := make(chan error, 1)
|
||||||
if err != nil {
|
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)
|
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 size int64
|
||||||
var fullObject bytes.Buffer
|
var fullObject bytes.Buffer
|
||||||
for i := 1; i <= len(parts.Part); i++ {
|
for i := 0; i < len(parts.Part); i++ {
|
||||||
recvMD5 := parts.Part[i-1].ETag
|
recvMD5 := parts.Part[i].ETag
|
||||||
object, ok := donut.multiPartObjects[uploadID].Get(parts.Part[i-1].PartNumber)
|
object, ok := donut.multiPartObjects[uploadID].Get(parts.Part[i].PartNumber)
|
||||||
if ok == false {
|
if ok == false {
|
||||||
donut.lock.Unlock()
|
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))
|
size += int64(len(object))
|
||||||
calcMD5Bytes := md5.Sum(object)
|
calcMD5Bytes := md5.Sum(object)
|
||||||
|
Loading…
Reference in New Issue
Block a user