|
|
@ -41,7 +41,7 @@ import ( |
|
|
|
// due to compatibility with older versions
|
|
|
|
// due to compatibility with older versions
|
|
|
|
// copied it to our rep
|
|
|
|
// copied it to our rep
|
|
|
|
|
|
|
|
|
|
|
|
"path/filepath" |
|
|
|
"path" |
|
|
|
|
|
|
|
|
|
|
|
minio "github.com/minio/minio-go" |
|
|
|
minio "github.com/minio/minio-go" |
|
|
|
"github.com/minio/minio-go/pkg/policy" |
|
|
|
"github.com/minio/minio-go/pkg/policy" |
|
|
@ -575,18 +575,18 @@ func (l *gcsGateway) DeleteObject(bucket string, object string) error { |
|
|
|
|
|
|
|
|
|
|
|
// ListMultipartUploads - lists all multipart uploads.
|
|
|
|
// ListMultipartUploads - lists all multipart uploads.
|
|
|
|
func (l *gcsGateway) ListMultipartUploads(bucket string, prefix string, keyMarker string, uploadIDMarker string, delimiter string, maxUploads int) (ListMultipartsInfo, error) { |
|
|
|
func (l *gcsGateway) ListMultipartUploads(bucket string, prefix string, keyMarker string, uploadIDMarker string, delimiter string, maxUploads int) (ListMultipartsInfo, error) { |
|
|
|
// TODO: implement prefix and prefixes, how does this work for Multiparts??
|
|
|
|
prefix = pathJoin(ZZZZMinioPrefix, "multipart-") |
|
|
|
prefix = fmt.Sprintf("%s/multipart-", ZZZZMinioPrefix) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|
|
|
|
|
|
|
|
|
isTruncated := false |
|
|
|
|
|
|
|
// prefixes := []string{}
|
|
|
|
|
|
|
|
nextMarker := "" |
|
|
|
nextMarker := "" |
|
|
|
|
|
|
|
isTruncated := false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it.PageInfo().Token = uploadIDMarker |
|
|
|
|
|
|
|
|
|
|
|
uploads := []uploadMetadata{} |
|
|
|
uploads := []uploadMetadata{} |
|
|
|
for { |
|
|
|
for { |
|
|
|
if maxUploads <= len(uploads) { |
|
|
|
if len(uploads) >= maxUploads { |
|
|
|
isTruncated = true |
|
|
|
isTruncated = true |
|
|
|
nextMarker = it.PageInfo().Token |
|
|
|
nextMarker = it.PageInfo().Token |
|
|
|
break |
|
|
|
break |
|
|
@ -610,6 +610,8 @@ func (l *gcsGateway) ListMultipartUploads(bucket string, prefix string, keyMarke |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextMarker = toGCSPageToken(attrs.Name) |
|
|
|
|
|
|
|
|
|
|
|
// we count only partID == 0
|
|
|
|
// we count only partID == 0
|
|
|
|
uploads = append(uploads, uploadMetadata{ |
|
|
|
uploads = append(uploads, uploadMetadata{ |
|
|
|
Object: objectKey, |
|
|
|
Object: objectKey, |
|
|
@ -634,7 +636,7 @@ func (l *gcsGateway) ListMultipartUploads(bucket string, prefix string, keyMarke |
|
|
|
|
|
|
|
|
|
|
|
func fromGCSMultipartKey(s string) (key, uploadID string, partID int, err error) { |
|
|
|
func fromGCSMultipartKey(s string) (key, uploadID string, partID int, err error) { |
|
|
|
// remove prefixes
|
|
|
|
// remove prefixes
|
|
|
|
s = filepath.Base(s) |
|
|
|
s = path.Base(s) |
|
|
|
|
|
|
|
|
|
|
|
parts := strings.Split(s, "-") |
|
|
|
parts := strings.Split(s, "-") |
|
|
|
if parts[0] != "multipart" { |
|
|
|
if parts[0] != "multipart" { |
|
|
@ -675,7 +677,7 @@ func toGCSMultipartKey(key string, uploadID string, partID int) string { |
|
|
|
// parts are allowed to be numbered from 1 to 10,000 (inclusive)
|
|
|
|
// parts are allowed to be numbered from 1 to 10,000 (inclusive)
|
|
|
|
|
|
|
|
|
|
|
|
// we need to encode the key because of possible slashes
|
|
|
|
// we need to encode the key because of possible slashes
|
|
|
|
return fmt.Sprintf("%s/multipart-%s-%s-%05d", ZZZZMinioPrefix, escape(key), uploadID, partID) |
|
|
|
return pathJoin(ZZZZMinioPrefix, fmt.Sprintf("multipart-%s-%s-%05d", escape(key), uploadID, partID)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewMultipartUpload - upload object in multiple parts
|
|
|
|
// NewMultipartUpload - upload object in multiple parts
|
|
|
@ -719,8 +721,8 @@ func (l *gcsGateway) PutObjectPart(bucket string, key string, uploadID string, p |
|
|
|
|
|
|
|
|
|
|
|
// ListObjectParts returns all object parts for specified object in specified bucket
|
|
|
|
// ListObjectParts returns all object parts for specified object in specified bucket
|
|
|
|
func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string, partNumberMarker int, maxParts int) (ListPartsInfo, error) { |
|
|
|
func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string, partNumberMarker int, maxParts int) (ListPartsInfo, error) { |
|
|
|
prefix := "" |
|
|
|
delimiter := slashSeparator |
|
|
|
delimiter := "/" |
|
|
|
prefix := pathJoin(ZZZZMinioPrefix, fmt.Sprintf("multipart-%s-%s", escape(key), uploadID)) |
|
|
|
|
|
|
|
|
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|
|
|
|
|
|
|
|
@ -741,9 +743,7 @@ func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string, |
|
|
|
attrs, err := it.Next() |
|
|
|
attrs, err := it.Next() |
|
|
|
if err == iterator.Done { |
|
|
|
if err == iterator.Done { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} else if err != nil { |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return ListPartsInfo{}, gcsToObjectError(traceError(err), bucket, prefix) |
|
|
|
return ListPartsInfo{}, gcsToObjectError(traceError(err), bucket, prefix) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -779,9 +779,8 @@ func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string, |
|
|
|
|
|
|
|
|
|
|
|
// AbortMultipartUpload aborts a ongoing multipart upload
|
|
|
|
// AbortMultipartUpload aborts a ongoing multipart upload
|
|
|
|
func (l *gcsGateway) AbortMultipartUpload(bucket string, key string, uploadID string) error { |
|
|
|
func (l *gcsGateway) AbortMultipartUpload(bucket string, key string, uploadID string) error { |
|
|
|
|
|
|
|
delimiter := slashSeparator |
|
|
|
delimiter := "/" |
|
|
|
prefix := pathJoin(ZZZZMinioPrefix, fmt.Sprintf("multipart-%s-%s", escape(key), uploadID)) |
|
|
|
prefix := fmt.Sprintf("%s/multipart-%s-%s", ZZZZMinioPrefix, key, uploadID) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// iterate through all parts and delete them
|
|
|
|
// iterate through all parts and delete them
|
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false}) |
|
|
|