mirror of
https://github.com/minio/minio.git
synced 2024-12-26 07:05:55 -05:00
Merge pull request #782 from krishnasrinivas/no-signature-no-sha256
when signature is not available there is no need to compute sha256
This commit is contained in:
commit
179c5441c3
@ -19,6 +19,7 @@ package donut
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@ -247,15 +248,23 @@ func (b bucket) WriteObject(objectName string, objectData io.Reader, size int64,
|
||||
return ObjectMetadata{}, iodine.New(err, nil)
|
||||
}
|
||||
sumMD5 := md5.New()
|
||||
sum256 := sha256.New()
|
||||
sum512 := sha512.New()
|
||||
var sum256 hash.Hash
|
||||
var mwriter io.Writer
|
||||
|
||||
if signature != nil {
|
||||
sum256 = sha256.New()
|
||||
mwriter = io.MultiWriter(sumMD5, sum256, sum512)
|
||||
} else {
|
||||
mwriter = io.MultiWriter(sumMD5, sum512)
|
||||
}
|
||||
objMetadata := ObjectMetadata{}
|
||||
objMetadata.Version = objectMetadataVersion
|
||||
objMetadata.Created = time.Now().UTC()
|
||||
// if total writers are only '1' do not compute erasure
|
||||
switch len(writers) == 1 {
|
||||
case true:
|
||||
mw := io.MultiWriter(writers[0], sumMD5, sum256, sum512)
|
||||
mw := io.MultiWriter(writers[0], mwriter)
|
||||
totalLength, err := io.Copy(mw, objectData)
|
||||
if err != nil {
|
||||
CleanupWritersOnError(writers)
|
||||
@ -269,7 +278,6 @@ func (b bucket) WriteObject(objectName string, objectData io.Reader, size int64,
|
||||
CleanupWritersOnError(writers)
|
||||
return ObjectMetadata{}, iodine.New(err, nil)
|
||||
}
|
||||
mwriter := io.MultiWriter(sumMD5, sum256, sum512)
|
||||
// write encoded data with k, m and writers
|
||||
chunkCount, totalLength, err := b.writeObjectData(k, m, writers, objectData, size, mwriter)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user