Update minio-go
This should work with Go 1.3/1.4 again
This commit is contained in:
parent
f8daadc5ef
commit
1464d84cf5
3 changed files with 58 additions and 5 deletions
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
|
@ -24,8 +24,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio/minio-go",
|
"ImportPath": "github.com/minio/minio-go",
|
||||||
"Comment": "v0.2.5-247-ge168a01",
|
"Comment": "v0.2.5-251-ga4cd3ca",
|
||||||
"Rev": "e168a01f2683897cc623db67f39ccff35bec0597"
|
"Rev": "a4cd3caabd5f9c35ac100110eb60c2b80798f1af"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/pkg/sftp",
|
"ImportPath": "github.com/pkg/sftp",
|
||||||
|
|
1
Godeps/_workspace/src/github.com/minio/minio-go/.travis.yml
generated
vendored
1
Godeps/_workspace/src/github.com/minio/minio-go/.travis.yml
generated
vendored
|
@ -14,6 +14,7 @@ go:
|
||||||
- 1.5.3
|
- 1.5.3
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- diff -au <(gofmt -d .) <(printf "")
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
- go test -short -race -v ./...
|
- go test -short -race -v ./...
|
||||||
|
|
||||||
|
|
58
Godeps/_workspace/src/github.com/minio/minio-go/api-put-object-common.go
generated
vendored
58
Godeps/_workspace/src/github.com/minio/minio-go/api-put-object-common.go
generated
vendored
|
@ -94,6 +94,58 @@ func optimalPartInfo(objectSize int64) (totalPartsCount int, partSize int64, las
|
||||||
return totalPartsCount, partSize, lastPartSize, nil
|
return totalPartsCount, partSize, lastPartSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compatibility code for Golang < 1.5.x.
|
||||||
|
// copyBuffer is identical to io.CopyBuffer, since such a function is
|
||||||
|
// not available/implemented in Golang version < 1.5.x, we use a
|
||||||
|
// custom call exactly implementng io.CopyBuffer from Golang > 1.5.x
|
||||||
|
// version does.
|
||||||
|
//
|
||||||
|
// copyBuffer stages through the provided buffer (if one is required)
|
||||||
|
// rather than allocating a temporary one. If buf is nil, one is
|
||||||
|
// allocated; otherwise if it has zero length, copyBuffer panics.
|
||||||
|
//
|
||||||
|
// FIXME: Remove this code when distributions move to newer Golang versions.
|
||||||
|
func copyBuffer(writer io.Writer, reader io.Reader, buf []byte) (written int64, err error) {
|
||||||
|
// If the reader has a WriteTo method, use it to do the copy.
|
||||||
|
// Avoids an allocation and a copy.
|
||||||
|
if wt, ok := reader.(io.WriterTo); ok {
|
||||||
|
return wt.WriteTo(writer)
|
||||||
|
}
|
||||||
|
// Similarly, if the writer has a ReadFrom method, use it to do
|
||||||
|
// the copy.
|
||||||
|
if rt, ok := writer.(io.ReaderFrom); ok {
|
||||||
|
return rt.ReadFrom(reader)
|
||||||
|
}
|
||||||
|
if buf == nil {
|
||||||
|
buf = make([]byte, 32*1024)
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
nr, er := reader.Read(buf)
|
||||||
|
if nr > 0 {
|
||||||
|
nw, ew := writer.Write(buf[0:nr])
|
||||||
|
if nw > 0 {
|
||||||
|
written += int64(nw)
|
||||||
|
}
|
||||||
|
if ew != nil {
|
||||||
|
err = ew
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if nr != nw {
|
||||||
|
err = io.ErrShortWrite
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if er == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if er != nil {
|
||||||
|
err = er
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return written, err
|
||||||
|
}
|
||||||
|
|
||||||
// hashCopyBuffer is identical to hashCopyN except that it stages
|
// hashCopyBuffer is identical to hashCopyN except that it stages
|
||||||
// through the provided buffer (if one is required) rather than
|
// through the provided buffer (if one is required) rather than
|
||||||
// allocating a temporary one. If buf is nil, one is allocated for 5MiB.
|
// allocating a temporary one. If buf is nil, one is allocated for 5MiB.
|
||||||
|
@ -113,9 +165,9 @@ func (c Client) hashCopyBuffer(writer io.Writer, reader io.Reader, buf []byte) (
|
||||||
buf = make([]byte, optimalReadBufferSize)
|
buf = make([]byte, optimalReadBufferSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using io.CopyBuffer to copy in large buffers, default buffer
|
// Using copyBuffer to copy in large buffers, default buffer
|
||||||
// for io.Copy of 32KiB is too small.
|
// for io.Copy of 32KiB is too small.
|
||||||
size, err = io.CopyBuffer(hashWriter, reader, buf)
|
size, err = copyBuffer(hashWriter, reader, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, 0, err
|
return nil, nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -215,7 +267,7 @@ func (c Client) computeHashBuffer(reader io.ReadSeeker, buf []byte) (md5Sum, sha
|
||||||
return nil, nil, 0, err
|
return nil, nil, 0, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size, err = io.CopyBuffer(hashWriter, reader, buf)
|
size, err = copyBuffer(hashWriter, reader, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, 0, err
|
return nil, nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue