mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Fix PutObject Trailing checksum (#20456)
PutObject would verify trailing checksums, but not store them. Fixes #20455
This commit is contained in:
@@ -335,6 +335,10 @@ func (c *Checksum) AppendTo(b []byte, parts []byte) []byte {
|
||||
var tmp [binary.MaxVarintLen32]byte
|
||||
n := binary.PutUvarint(tmp[:], uint64(c.Type))
|
||||
crc := c.Raw
|
||||
if c.Type.Trailing() {
|
||||
// When we serialize we don't care if it was trailing.
|
||||
c.Type ^= ChecksumTrailing
|
||||
}
|
||||
if len(crc) != c.Type.RawByteLen() {
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -366,6 +366,14 @@ func (r *Reader) ContentCRC() map[string]string {
|
||||
return map[string]string{r.contentHash.Type.String(): r.contentHash.Encoded}
|
||||
}
|
||||
|
||||
// Checksum returns the content checksum if set.
|
||||
func (r *Reader) Checksum() *Checksum {
|
||||
if !r.contentHash.Type.IsSet() || !r.contentHash.Valid() {
|
||||
return nil
|
||||
}
|
||||
return &r.contentHash
|
||||
}
|
||||
|
||||
var _ io.Closer = (*Reader)(nil) // compiler check
|
||||
|
||||
// Close and release resources.
|
||||
|
||||
Reference in New Issue
Block a user