mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Send length instead of empty buffer for ReadFile() (#6414)
This commit is contained in:
parent
9e32cc283f
commit
81b7e5c7a8
@ -227,7 +227,7 @@ func (client *StorageRPCClient) ReadFile(volume string, path string, offset int6
|
||||
Vol: volume,
|
||||
Path: path,
|
||||
Offset: offset,
|
||||
Buffer: buffer,
|
||||
Length: int64(len(buffer)),
|
||||
Verified: true, // mark read as verified by default
|
||||
}
|
||||
if verifier != nil {
|
||||
|
@ -127,7 +127,7 @@ type ReadFileArgs struct {
|
||||
Vol string
|
||||
Path string
|
||||
Offset int64
|
||||
Buffer []byte
|
||||
Length int64
|
||||
Algo BitrotAlgorithm
|
||||
ExpectedHash []byte
|
||||
Verified bool
|
||||
@ -140,13 +140,14 @@ func (receiver *storageRPCReceiver) ReadFile(args *ReadFileArgs, reply *[]byte)
|
||||
verifier = NewBitrotVerifier(args.Algo, args.ExpectedHash)
|
||||
}
|
||||
|
||||
n, err := receiver.local.ReadFile(args.Vol, args.Path, args.Offset, args.Buffer, verifier)
|
||||
buf := make([]byte, args.Length)
|
||||
n, err := receiver.local.ReadFile(args.Vol, args.Path, args.Offset, buf, verifier)
|
||||
// Ignore io.ErrEnexpectedEOF for short reads i.e. less content available than requested.
|
||||
if err == io.ErrUnexpectedEOF {
|
||||
err = nil
|
||||
}
|
||||
|
||||
*reply = args.Buffer[0:n]
|
||||
*reply = buf[0:n]
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user