|
|
@ -68,12 +68,20 @@ func (storage *appendStorage) Get(objectPath string) (io.Reader, error) { |
|
|
|
|
|
|
|
|
|
|
|
offset := header.Offset |
|
|
|
offset := header.Offset |
|
|
|
length := header.Length |
|
|
|
length := header.Length |
|
|
|
|
|
|
|
crc := header.Crc |
|
|
|
|
|
|
|
|
|
|
|
object := make([]byte, length) |
|
|
|
object := make([]byte, length) |
|
|
|
_, err := storage.file.ReadAt(object, offset) |
|
|
|
_, err := storage.file.ReadAt(object, offset) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
newcrc, err := crc32c.Crc32c(object) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if newcrc != crc { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
return bytes.NewBuffer(object), nil |
|
|
|
return bytes.NewBuffer(object), nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|