|
|
@ -19,6 +19,7 @@ package v1 |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/binary" |
|
|
|
"encoding/binary" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/minio-io/minio/pkg/utils/checksum/crc32c" |
|
|
|
"github.com/minio-io/minio/pkg/utils/checksum/crc32c" |
|
|
@ -101,10 +102,13 @@ func Write(target io.Writer, reader io.Reader, length uint64) error { |
|
|
|
checksumChannel := make(chan checksumValue) |
|
|
|
checksumChannel := make(chan checksumValue) |
|
|
|
go generateChecksum(sumReader, checksumChannel) |
|
|
|
go generateChecksum(sumReader, checksumChannel) |
|
|
|
teeReader := io.TeeReader(reader, sumWriter) |
|
|
|
teeReader := io.TeeReader(reader, sumWriter) |
|
|
|
_, err = io.Copy(target, teeReader) |
|
|
|
dataLength, err := io.Copy(target, teeReader) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if uint64(dataLength) != length { |
|
|
|
|
|
|
|
return errors.New("Specified data length and amount written mismatched") |
|
|
|
|
|
|
|
} |
|
|
|
sumWriter.Close() |
|
|
|
sumWriter.Close() |
|
|
|
dataChecksum := <-checksumChannel |
|
|
|
dataChecksum := <-checksumChannel |
|
|
|
if dataChecksum.err != nil { |
|
|
|
if dataChecksum.err != nil { |
|
|
|