From 2a8535626f0845dbfc0ce424327c054e39549fe7 Mon Sep 17 00:00:00 2001 From: tgic Date: Sat, 4 Jul 2015 23:53:00 +0800 Subject: [PATCH] fix oss: got 403 in TestContinueStreamAppendLarge Signed-off-by: tgic --- Godeps/Godeps.json | 4 ++-- .../src/github.com/denverdino/aliyungo/oss/multi.go | 8 ++++++-- registry/storage/driver/oss/oss.go | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3dbf5326..9fb51c3e 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -46,11 +46,11 @@ }, { "ImportPath": "github.com/denverdino/aliyungo/oss", - "Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0" + "Rev": "0e0f322d0a54b994dea9d32541050d177edf6aa3" }, { "ImportPath": "github.com/denverdino/aliyungo/util", - "Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0" + "Rev": "0e0f322d0a54b994dea9d32541050d177edf6aa3" }, { "ImportPath": "github.com/docker/docker/pkg/tarsum", diff --git a/Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go b/Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go index 454d53b7..5b6491ec 100644 --- a/Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go +++ b/Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go @@ -139,6 +139,9 @@ func (b *Bucket) InitMulti(key string, contType string, perm ACL, options Option } func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error) { + // TODO source format a /BUCKET/PATH/TO/OBJECT + // TODO not a good design. API could be changed to PutPartCopyWithinBucket(..., path) and PutPartCopyFromBucket(bucket, path) + headers := make(http.Header) headers.Set("x-oss-copy-source", source) @@ -150,8 +153,9 @@ func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObj sourceBucket := m.Bucket.Client.Bucket(strings.TrimRight(strings.Split(source, "/")[1], "/")) //log.Println("source: ", source) //log.Println("sourceBucket: ", sourceBucket.Name) - //log.Println("HEAD: ", strings.Split(source, "/")[2]) - sourceMeta, err := sourceBucket.Head(strings.Split(source, "/")[2], nil) + //log.Println("HEAD: ", strings.strings.SplitAfterN(source, "/", 3)[2]) + // TODO SplitAfterN can be use in bucket name + sourceMeta, err := sourceBucket.Head(strings.SplitAfterN(source, "/", 3)[2], nil) if err != nil { return nil, Part{}, err } diff --git a/registry/storage/driver/oss/oss.go b/registry/storage/driver/oss/oss.go index 21a7e32a..b3ab11c9 100644 --- a/registry/storage/driver/oss/oss.go +++ b/registry/storage/driver/oss/oss.go @@ -492,7 +492,7 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea // currentLength >= offset >= chunkSize _, part, err = multi.PutPartCopy(partNumber, oss.CopyOptions{CopySourceOptions: "bytes=0-" + strconv.FormatInt(offset-1, 10)}, - d.Bucket.Name+"/"+d.ossPath(path)) + d.Bucket.Path(d.ossPath(path))) if err != nil { return 0, err } @@ -586,7 +586,7 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea // offset > currentLength >= chunkSize _, part, err = multi.PutPartCopy(partNumber, oss.CopyOptions{}, - d.Bucket.Name+"/"+d.ossPath(path)) + d.Bucket.Path(d.ossPath(path))) if err != nil { return 0, err }