mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
do not log checksum mismatch error, client received the error (#16246)
This commit is contained in:
parent
0159b56717
commit
c73ea27ed7
@ -22,6 +22,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/minio/minio/internal/hash"
|
||||
"github.com/minio/minio/internal/logger"
|
||||
)
|
||||
|
||||
@ -83,9 +84,16 @@ func (e *Erasure) Encode(ctx context.Context, src io.Reader, writers []io.Writer
|
||||
for {
|
||||
var blocks [][]byte
|
||||
n, err := io.ReadFull(src, buf)
|
||||
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
|
||||
logger.LogIf(ctx, err)
|
||||
return 0, err
|
||||
if err != nil {
|
||||
if !IsErrIgnored(err, []error{
|
||||
io.EOF,
|
||||
io.ErrUnexpectedEOF,
|
||||
}...) {
|
||||
if !hash.IsChecksumMismatch(err) {
|
||||
logger.LogIf(ctx, err)
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
eof := err == io.EOF || err == io.ErrUnexpectedEOF
|
||||
if n == 0 && total != 0 {
|
||||
|
@ -17,7 +17,10 @@
|
||||
|
||||
package hash
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SHA256Mismatch - when content sha256 does not match with what was sent from client.
|
||||
type SHA256Mismatch struct {
|
||||
@ -58,3 +61,9 @@ type ChecksumMismatch struct {
|
||||
func (e ChecksumMismatch) Error() string {
|
||||
return "Bad checksum: Want " + e.Want + " does not match calculated " + e.Got
|
||||
}
|
||||
|
||||
// IsChecksumMismatch matches if 'err' is hash.ChecksumMismatch
|
||||
func IsChecksumMismatch(err error) bool {
|
||||
var herr ChecksumMismatch
|
||||
return errors.As(err, &herr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user