mirror of
https://github.com/minio/minio.git
synced 2025-01-12 23:43:22 -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)
|
footerBuffer := make([]byte, 80)
|
||||||
reader.Read(footerBuffer)
|
reader.Read(footerBuffer)
|
||||||
expectedCrc := binary.LittleEndian.Uint32(footerBuffer[:4])
|
expectedCrc := binary.LittleEndian.Uint32(footerBuffer[:4])
|
||||||
|
|
||||||
actualCrc := crc32c.Sum32(footerBuffer[4:])
|
actualCrc := crc32c.Sum32(footerBuffer[4:])
|
||||||
|
|
||||||
if expectedCrc != actualCrc {
|
if expectedCrc != actualCrc {
|
||||||
// TODO perhaps we should return data and still report error?
|
// TODO perhaps we should return data and still report error?
|
||||||
return nil, errors.New("Expected CRC doesn't match for footer")
|
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 {
|
if headerLength != 32 {
|
||||||
return header, errors.New("EOF found while reading donut header")
|
return header, errors.New("EOF found while reading donut header")
|
||||||
}
|
}
|
||||||
|
|
||||||
actualCrc := crc32c.Sum32(headerSlice[:24])
|
actualCrc := crc32c.Sum32(headerSlice[:24])
|
||||||
|
|
||||||
expectedCrc := binary.LittleEndian.Uint32(headerSlice[24:28])
|
expectedCrc := binary.LittleEndian.Uint32(headerSlice[24:28])
|
||||||
|
|
||||||
if actualCrc != expectedCrc {
|
if actualCrc != expectedCrc {
|
||||||
return header, errors.New("CRC for donut did not match")
|
return header, errors.New("CRC for donut did not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = binary.Read(bytes.NewBuffer(headerSlice[0:24]), binary.LittleEndian, &header)
|
err = binary.Read(bytes.NewBuffer(headerSlice[0:24]), binary.LittleEndian, &header)
|
||||||
|
|
||||||
return header, nil
|
return header, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +211,7 @@ type checksumValue struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate sha512 over channel
|
||||||
func generateChecksum(reader io.Reader, c chan<- checksumValue) {
|
func generateChecksum(reader io.Reader, c chan<- checksumValue) {
|
||||||
checksum, err := sha512.SumStream(reader)
|
checksum, err := sha512.SumStream(reader)
|
||||||
result := checksumValue{
|
result := checksumValue{
|
||||||
|
@ -37,11 +37,10 @@ var _ = Suite(&MySuite{})
|
|||||||
func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
data := "Hello, World"
|
data := []byte("Hello, World")
|
||||||
|
|
||||||
hash := md5.New()
|
hash := md5.New()
|
||||||
hash.Sum([]byte(data))
|
sum := hash.Sum(data)
|
||||||
sum := hash.Sum(nil)
|
|
||||||
|
|
||||||
objectMetadata := ObjectMetadata{
|
objectMetadata := ObjectMetadata{
|
||||||
Bucket: "bucket",
|
Bucket: "bucket",
|
||||||
@ -56,7 +55,7 @@ func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
|||||||
Length: uint64(len(sum)),
|
Length: uint64(len(sum)),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := Write(&buffer, objectMetadata, bytes.NewBufferString(data))
|
err := Write(&buffer, objectMetadata, bytes.NewBuffer(data))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
versionBuffer := make([]byte, 4)
|
versionBuffer := make([]byte, 4)
|
||||||
@ -73,5 +72,5 @@ func (s *MySuite) TestObjectV1ReadWrite(c *C) {
|
|||||||
|
|
||||||
_, err = io.Copy(&actualData, &buffer)
|
_, err = io.Copy(&actualData, &buffer)
|
||||||
c.Assert(err, IsNil)
|
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