From f5437632f486b7d0a0a181c58f113c86d032b02c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 24 Apr 2017 20:11:36 -0400 Subject: Upgrading server dependancies (#6215) --- vendor/github.com/minio/minio-go/api-get-object.go | 37 ++++++++-------------- 1 file changed, 14 insertions(+), 23 deletions(-) (limited to 'vendor/github.com/minio/minio-go/api-get-object.go') diff --git a/vendor/github.com/minio/minio-go/api-get-object.go b/vendor/github.com/minio/minio-go/api-get-object.go index c9b4dcedd..48ee947ff 100644 --- a/vendor/github.com/minio/minio-go/api-get-object.go +++ b/vendor/github.com/minio/minio-go/api-get-object.go @@ -212,10 +212,12 @@ type Object struct { reqCh chan<- getRequest resCh <-chan getResponse doneCh chan<- struct{} - prevOffset int64 currOffset int64 objectInfo ObjectInfo + // Ask lower level to initiate data fetching based on currOffset + seekData bool + // Keeps track of closed call. isClosed bool @@ -258,6 +260,10 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) { if response.Error != nil { return response, response.Error } + + // Data are ready on the wire, no need to reinitiate connection in lower level + o.seekData = false + return response, nil } @@ -266,8 +272,6 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) { func (o *Object) setOffset(bytesRead int64) error { // Update the currentOffset. o.currOffset += bytesRead - // Save the current offset as previous offset. - o.prevOffset = o.currOffset if o.currOffset >= o.objectInfo.Size { return io.EOF @@ -303,22 +307,9 @@ func (o *Object) Read(b []byte) (n int, err error) { readReq.isFirstReq = true } - // Verify if offset has changed and currOffset is greater than - // previous offset. Perhaps due to Seek(). - offsetChange := o.prevOffset - o.currOffset - if offsetChange < 0 { - offsetChange = -offsetChange - } - if offsetChange > 0 { - // Fetch the new reader at the current offset again. - readReq.Offset = o.currOffset - readReq.DidOffsetChange = true - } else { - // No offset changes no need to fetch new reader, continue - // reading. - readReq.DidOffsetChange = false - readReq.Offset = 0 - } + // Ask to establish a new data fetch routine based on seekData flag + readReq.DidOffsetChange = o.seekData + readReq.Offset = o.currOffset // Send and receive from the first request. response, err := o.doGetRequest(readReq) @@ -430,8 +421,6 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) { if !o.objectInfoSet { // Update the currentOffset. o.currOffset += bytesRead - // Save the current offset as previous offset. - o.prevOffset = o.currOffset } else { // If this was not the first request update // the offsets and compare against objectInfo @@ -492,8 +481,6 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) { return 0, err } } - // Save current offset as previous offset. - o.prevOffset = o.currOffset // Switch through whence. switch whence { @@ -527,6 +514,10 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) { if o.prevErr == io.EOF { o.prevErr = nil } + + // Ask lower level to fetch again from source + o.seekData = true + // Return the effective offset. return o.currOffset, nil } -- cgit v1.2.3-1-g7c22