forked from TrueCloudLab/frostfs-sdk-go
[#149] client: Fix false io.ErrUnexpectedEOF
return
In previous implementation `Close` method of `ObjectReader` / `ObjectRangeReader` could incorrectly return `io.ErrUnexpectedEOF` of payload wasn't read by `Read` method (in this case `remainingPayloadLen` state var is not updated). Return `io.ErrUnexpectedEOF` from `Read` method only. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2adbe29f7f
commit
b5874778e9
1 changed files with 8 additions and 4 deletions
|
@ -223,9 +223,11 @@ func (x *ObjectReader) close(ignoreEOF bool) (*ResObjectGet, error) {
|
|||
if x.ctxCall.err != nil {
|
||||
if !errors.Is(x.ctxCall.err, io.EOF) {
|
||||
return nil, x.ctxCall.err
|
||||
} else if x.remainingPayloadLen > 0 {
|
||||
return nil, io.ErrUnexpectedEOF
|
||||
} else if !ignoreEOF {
|
||||
if x.remainingPayloadLen > 0 {
|
||||
return nil, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
return nil, io.EOF
|
||||
}
|
||||
}
|
||||
|
@ -663,9 +665,11 @@ func (x *ObjectRangeReader) close(ignoreEOF bool) (*ResObjectRange, error) {
|
|||
if x.ctxCall.err != nil {
|
||||
if !errors.Is(x.ctxCall.err, io.EOF) {
|
||||
return nil, x.ctxCall.err
|
||||
} else if x.remainingPayloadLen > 0 {
|
||||
return nil, io.ErrUnexpectedEOF
|
||||
} else if !ignoreEOF {
|
||||
if x.remainingPayloadLen > 0 {
|
||||
return nil, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
return nil, io.EOF
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue