diff --git a/.travis.yml b/.travis.yml index 30f8ccc0..ab3d7297 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - ARCH=i686 go: -- 1.7.3 +- 1.8 script: - make test GOFLAGS="-race" diff --git a/Dockerfile b/Dockerfile index bf949cf4..b1a81211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.7-alpine +FROM golang:1.8-alpine WORKDIR /go/src/app diff --git a/appveyor.yml b/appveyor.yml index 3e16dd95..d8947223 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,11 +8,15 @@ clone_folder: c:\gopath\src\github.com\minio\mc # environment variables environment: + GOVERSION: 1.8 GOPATH: c:\gopath # scripts that run after cloning repository install: - set PATH=%GOPATH%\bin;c:\go\bin;%PATH% + - rmdir c:\go /s /q + - appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.zip + - 7z x go%GOVERSION%.windows-amd64.zip -y -oC:\ > NUL - go version - go env diff --git a/cmd/globals.go b/cmd/globals.go index f806d666..147df631 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -26,7 +26,7 @@ import ( // mc configuration related constants. const ( - minGoVersion = ">= 1.7.1" // mc requires at least Go v1.7.1 + minGoVersion = ">= 1.8" // mc requires at least Go v1.8 ) const ( diff --git a/cmd/mc_test.go b/cmd/mc_test.go index 11aee25c..367fc4ab 100644 --- a/cmd/mc_test.go +++ b/cmd/mc_test.go @@ -116,10 +116,10 @@ func (s *TestSuite) TestHumanizedTime(c *C) { } func (s *TestSuite) TestVersions(c *C) { - v1, e := version.NewVersion("1.7.1") - v2, e := version.NewVersion("1.6.3") + v1, e := version.NewVersion("1.8") + v2, e := version.NewVersion("1.7") c.Assert(e, IsNil) - constraint, e := version.NewConstraint(">= 1.7.1") + constraint, e := version.NewConstraint(">= 1.8") c.Assert(e, IsNil) c.Assert(constraint.Check(v1), Equals, true) c.Assert(constraint.Check(v2), Equals, false) 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 c9b4dced..48ee947f 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 } diff --git a/vendor/github.com/minio/minio-go/api-put-object-common.go b/vendor/github.com/minio/minio-go/api-put-object-common.go index 5f5f568e..3384d7b2 100644 --- a/vendor/github.com/minio/minio-go/api-put-object-common.go +++ b/vendor/github.com/minio/minio-go/api-put-object-common.go @@ -161,7 +161,7 @@ func hashCopyN(hashAlgorithms map[string]hash.Hash, hashSums map[string][]byte, for k, v := range hashAlgorithms { hashSums[k] = v.Sum(nil) } - return size, err + return size, nil } // getUploadID - fetch upload id if already present for an object name diff --git a/vendor/github.com/minio/minio-go/api-put-object-multipart.go b/vendor/github.com/minio/minio-go/api-put-object-multipart.go index f74eae62..e2922036 100644 --- a/vendor/github.com/minio/minio-go/api-put-object-multipart.go +++ b/vendor/github.com/minio/minio-go/api-put-object-multipart.go @@ -114,9 +114,7 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i // Calculates hash sums while copying partSize bytes into tmpBuffer. prtSize, rErr := hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, partSize) if rErr != nil { - if rErr != io.EOF { - return 0, rErr - } + return 0, rErr } var reader io.Reader diff --git a/vendor/github.com/minio/minio-go/api-put-object.go b/vendor/github.com/minio/minio-go/api-put-object.go index a779fbeb..4a6781b6 100644 --- a/vendor/github.com/minio/minio-go/api-put-object.go +++ b/vendor/github.com/minio/minio-go/api-put-object.go @@ -209,6 +209,9 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader, // Initialize a new temporary buffer. tmpBuffer := new(bytes.Buffer) size, err = hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, size) + if err != nil { + return 0, err + } reader = bytes.NewReader(tmpBuffer.Bytes()) tmpBuffer.Reset() } else { @@ -229,12 +232,7 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader, } reader = tmpFile } - // Return error if its not io.EOF. - if err != nil { - if err != io.EOF { - return 0, err - } - } + // Execute put object. st, err := c.putObjectDo(bucketName, objectName, reader, hashSums["md5"], hashSums["sha256"], size, metaData) if err != nil { diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go index 1231ddf4..8bcdc0d7 100644 --- a/vendor/github.com/minio/minio-go/api.go +++ b/vendor/github.com/minio/minio-go/api.go @@ -81,7 +81,7 @@ type Client struct { // Global constants. const ( libraryName = "minio-go" - libraryVersion = "2.0.3" + libraryVersion = "2.0.4" ) // User Agent should always following the below style. @@ -588,7 +588,7 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R } // Initialize a new HTTP request for the method. - req, err = http.NewRequest(method, targetURL.String(), nil) + req, err = http.NewRequest(method, targetURL.String(), metadata.contentBody) if err != nil { return nil, err } @@ -608,11 +608,6 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R return req, nil } - // Set content body if available. - if metadata.contentBody != nil { - req.Body = ioutil.NopCloser(metadata.contentBody) - } - // FIXME: Enable this when Google Cloud Storage properly supports 100-continue. // Skip setting 'expect' header for Google Cloud Storage, there // are some known issues - https://github.com/restic/restic/issues/520 diff --git a/vendor/github.com/minio/minio-go/copy-conditions.go b/vendor/github.com/minio/minio-go/copy-conditions.go index 5dcdfaef..65018aa0 100644 --- a/vendor/github.com/minio/minio-go/copy-conditions.go +++ b/vendor/github.com/minio/minio-go/copy-conditions.go @@ -41,11 +41,13 @@ type CopyConditions struct { conditions []copyCondition } -// NewCopyConditions - Instantiate new list of conditions. +// NewCopyConditions - Instantiate new list of conditions. This +// function is left behind for backward compatibility. The idiomatic +// way to set an empty set of copy conditions is, +// ``copyConditions := CopyConditions{}``. +// func NewCopyConditions() CopyConditions { - return CopyConditions{ - conditions: make([]copyCondition, 0), - } + return CopyConditions{} } // SetMatchETag - set match etag. diff --git a/vendor/vendor.json b/vendor/vendor.json index 53662680..9a9856fb 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -50,10 +50,10 @@ "revisionTime": "2015-10-24T22:24:27-07:00" }, { - "checksumSHA1": "2FrFoR0UtufaCGRxM4UxP1fR3LM=", + "checksumSHA1": "InJ8MZLIDbv2KJk2tiyHUHOuRHE=", "path": "github.com/minio/minio-go", - "revision": "952412b95ae05cced91069ddc97b108a675ca1d1", - "revisionTime": "2017-01-05T09:15:05Z" + "revision": "7a3619e41885dcbcfafee193c10eb80530c2be53", + "revisionTime": "2017-02-17T20:03:45Z" }, { "checksumSHA1": "qTxOBp3GVxCC70ykb7Hxg6UgWwA=",