summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/api-get-object.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-get-object.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/api-get-object.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-get-object.go b/vendor/github.com/minio/minio-go/v7/api-get-object.go
index e31e4cf92..9e6b1543c 100644
--- a/vendor/github.com/minio/minio-go/v7/api-get-object.go
+++ b/vendor/github.com/minio/minio-go/v7/api-get-object.go
@@ -550,6 +550,8 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
}
}
+ newOffset := o.currOffset
+
// Switch through whence.
switch whence {
default:
@@ -558,12 +560,12 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
if o.objectInfo.Size > -1 && offset > o.objectInfo.Size {
return 0, io.EOF
}
- o.currOffset = offset
+ newOffset = offset
case 1:
if o.objectInfo.Size > -1 && o.currOffset+offset > o.objectInfo.Size {
return 0, io.EOF
}
- o.currOffset += offset
+ newOffset += offset
case 2:
// If we don't know the object size return an error for io.SeekEnd
if o.objectInfo.Size < 0 {
@@ -579,7 +581,7 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
if o.objectInfo.Size+offset < 0 {
return 0, errInvalidArgument(fmt.Sprintf("Seeking at negative offset not allowed for %d", whence))
}
- o.currOffset = o.objectInfo.Size + offset
+ newOffset = o.objectInfo.Size + offset
}
// Reset the saved error since we successfully seeked, let the Read
// and ReadAt decide.
@@ -587,8 +589,9 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
o.prevErr = nil
}
- // Ask lower level to fetch again from source
- o.seekData = true
+ // Ask lower level to fetch again from source when necessary
+ o.seekData = (newOffset != o.currOffset) || o.seekData
+ o.currOffset = newOffset
// Return the effective offset.
return o.currOffset, nil