Merge pull request #291 from harshavardhana/pr_out_cosmetic_changes

master
Harshavardhana 10 years ago
commit 959d482614
  1. 7
      pkg/storage/donut/fragment/fragment1/fragment.go
  2. 9
      pkg/storage/donut/object/objectv1/objectv1_test.go
  3. 0
      pkg/storage/storage_date.go

@ -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])
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…
Cancel
Save