mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
Cosmetic changes
This commit is contained in:
parent
1e4a47ac5f
commit
f7fd526b28
@ -169,8 +169,8 @@ func Read(reader io.Reader) (io.Reader, error) {
|
||||
footerBuffer := make([]byte, 80)
|
||||
reader.Read(footerBuffer)
|
||||
expectedCrc := binary.LittleEndian.Uint32(footerBuffer[:4])
|
||||
|
||||
actualCrc := crc32c.Sum32(footerBuffer[4:])
|
||||
|
||||
if expectedCrc != actualCrc {
|
||||
// TODO perhaps we should return data and still report error?
|
||||
return nil, errors.New("Expected CRC doesn't match for footer")
|
||||
@ -195,16 +195,14 @@ func ReadHeader(reader io.Reader) (header DonutFrameHeader, err error) {
|
||||
if headerLength != 32 {
|
||||
return header, errors.New("EOF found while reading donut header")
|
||||
}
|
||||
|
||||
actualCrc := crc32c.Sum32(headerSlice[:24])
|
||||
|
||||
expectedCrc := binary.LittleEndian.Uint32(headerSlice[24:28])
|
||||
|
||||
if actualCrc != expectedCrc {
|
||||
return header, errors.New("CRC for donut did not match")
|
||||
}
|
||||
|
||||
err = binary.Read(bytes.NewBuffer(headerSlice[0:24]), binary.LittleEndian, &header)
|
||||
|
||||
return header, nil
|
||||
}
|
||||
|
||||
@ -213,6 +211,7 @@ type checksumValue struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// calculate sha512 over channel
|
||||
func generateChecksum(reader io.Reader, c chan<- checksumValue) {
|
||||
checksum, err := sha512.SumStream(reader)
|
||||
result := checksumValue{
|
||||
|
@ -37,11 +37,10 @@ var _ = Suite(&MySuite{})
|
||||
func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
data := "Hello, World"
|
||||
data := []byte("Hello, World")
|
||||
|
||||
hash := md5.New()
|
||||
hash.Sum([]byte(data))
|
||||
sum := hash.Sum(nil)
|
||||
sum := hash.Sum(data)
|
||||
|
||||
objectMetadata := ObjectMetadata{
|
||||
Bucket: "bucket",
|
||||
@ -56,7 +55,7 @@ func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
||||
Length: uint64(len(sum)),
|
||||
}
|
||||
|
||||
err := Write(&buffer, objectMetadata, bytes.NewBufferString(data))
|
||||
err := Write(&buffer, objectMetadata, bytes.NewBuffer(data))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
versionBuffer := make([]byte, 4)
|
||||
@ -73,5 +72,5 @@ func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
||||
|
||||
_, err = io.Copy(&actualData, &buffer)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(actualData.Bytes(), DeepEquals, []byte(data))
|
||||
c.Assert(actualData.Bytes(), DeepEquals, data)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user