mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Simplify data verification with HashReader. (#5071)
Verify() was being called by caller after the data has been successfully read after io.EOF. This disconnection opens a race under concurrent access to such an object. Verification is not necessary outside of Read() call, we can simply just do checksum verification right inside Read() call at io.EOF. This approach simplifies the usage.
This commit is contained in:
committed by
Nitish Tiwari
parent
65a817fe8c
commit
1d8a8c63db
@@ -53,6 +53,7 @@ import (
|
||||
"github.com/fatih/color"
|
||||
router "github.com/gorilla/mux"
|
||||
"github.com/minio/minio-go/pkg/s3signer"
|
||||
"github.com/minio/minio/pkg/hash"
|
||||
)
|
||||
|
||||
// Tests should initNSLock only once.
|
||||
@@ -129,6 +130,14 @@ func calculateSignedChunkLength(chunkDataSize int64) int64 {
|
||||
2 // CRLF
|
||||
}
|
||||
|
||||
func mustGetHashReader(t TestErrHandler, data io.Reader, size int64, md5hex, sha256hex string) *hash.Reader {
|
||||
hr, err := hash.NewReader(data, size, md5hex, sha256hex)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return hr
|
||||
}
|
||||
|
||||
// calculateSignedChunkLength - calculates the length of the overall stream (data + metadata)
|
||||
func calculateStreamContentLength(dataLen, chunkSize int64) int64 {
|
||||
if dataLen <= 0 {
|
||||
@@ -1975,6 +1984,7 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
|
||||
if err != nil {
|
||||
t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
|
||||
}
|
||||
|
||||
// Executing the object layer tests for single node setup.
|
||||
objTest(objLayer, FSTestStr, t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user