summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/api-list.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-list.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/api-list.go98
1 files changed, 63 insertions, 35 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-list.go b/vendor/github.com/minio/minio-go/v7/api-list.go
index b624b0778..d216afb39 100644
--- a/vendor/github.com/minio/minio-go/v7/api-list.go
+++ b/vendor/github.com/minio/minio-go/v7/api-list.go
@@ -32,11 +32,10 @@ import (
// This call requires explicit authentication, no anonymous requests are
// allowed for listing buckets.
//
-// api := client.New(....)
-// for message := range api.ListBuckets(context.Background()) {
-// fmt.Println(message)
-// }
-//
+// api := client.New(....)
+// for message := range api.ListBuckets(context.Background()) {
+// fmt.Println(message)
+// }
func (c *Client) ListBuckets(ctx context.Context) ([]BucketInfo, error) {
// Execute GET on service.
resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{contentSHA256Hex: emptySHA256Hex})
@@ -71,21 +70,28 @@ func (c *Client) listObjectsV2(ctx context.Context, bucketName string, opts List
// Return object owner information by default
fetchOwner := true
+ sendObjectInfo := func(info ObjectInfo) {
+ select {
+ case objectStatCh <- info:
+ case <-ctx.Done():
+ }
+ }
+
// Validate bucket name.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
defer close(objectStatCh)
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return objectStatCh
}
// Validate incoming object prefix.
if err := s3utils.CheckValidObjectNamePrefix(opts.Prefix); err != nil {
defer close(objectStatCh)
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return objectStatCh
}
@@ -99,9 +105,9 @@ func (c *Client) listObjectsV2(ctx context.Context, bucketName string, opts List
result, err := c.listObjectsV2Query(ctx, bucketName, opts.Prefix, continuationToken,
fetchOwner, opts.WithMetadata, delimiter, opts.StartAfter, opts.MaxKeys, opts.headers)
if err != nil {
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return
}
@@ -138,6 +144,14 @@ func (c *Client) listObjectsV2(ctx context.Context, bucketName string, opts List
if !result.IsTruncated {
return
}
+
+ // Add this to catch broken S3 API implementations.
+ if continuationToken == "" {
+ sendObjectInfo(ObjectInfo{
+ Err: fmt.Errorf("listObjectsV2 is truncated without continuationToken, %s S3 server is incompatible with S3 API", c.endpointURL),
+ })
+ return
+ }
}
}(objectStatCh)
return objectStatCh
@@ -263,20 +277,28 @@ func (c *Client) listObjects(ctx context.Context, bucketName string, opts ListOb
// If recursive we do not delimit.
delimiter = ""
}
+
+ sendObjectInfo := func(info ObjectInfo) {
+ select {
+ case objectStatCh <- info:
+ case <-ctx.Done():
+ }
+ }
+
// Validate bucket name.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
defer close(objectStatCh)
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return objectStatCh
}
// Validate incoming object prefix.
if err := s3utils.CheckValidObjectNamePrefix(opts.Prefix); err != nil {
defer close(objectStatCh)
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return objectStatCh
}
@@ -289,9 +311,9 @@ func (c *Client) listObjects(ctx context.Context, bucketName string, opts ListOb
// Get list of objects a maximum of 1000 per request.
result, err := c.listObjectsQuery(ctx, bucketName, opts.Prefix, marker, delimiter, opts.MaxKeys, opts.headers)
if err != nil {
- objectStatCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return
}
@@ -344,21 +366,28 @@ func (c *Client) listObjectVersions(ctx context.Context, bucketName string, opts
delimiter = ""
}
+ sendObjectInfo := func(info ObjectInfo) {
+ select {
+ case resultCh <- info:
+ case <-ctx.Done():
+ }
+ }
+
// Validate bucket name.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
defer close(resultCh)
- resultCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return resultCh
}
// Validate incoming object prefix.
if err := s3utils.CheckValidObjectNamePrefix(opts.Prefix); err != nil {
defer close(resultCh)
- resultCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return resultCh
}
@@ -375,9 +404,9 @@ func (c *Client) listObjectVersions(ctx context.Context, bucketName string, opts
// Get list of objects a maximum of 1000 per request.
result, err := c.listObjectVersionsQuery(ctx, bucketName, opts.Prefix, keyMarker, versionIDMarker, delimiter, opts.MaxKeys, opts.headers)
if err != nil {
- resultCh <- ObjectInfo{
+ sendObjectInfo(ObjectInfo{
Err: err,
- }
+ })
return
}
@@ -659,11 +688,10 @@ func (o *ListObjectsOptions) Set(key, value string) {
// ListObjects returns objects list after evaluating the passed options.
//
-// api := client.New(....)
-// for object := range api.ListObjects(ctx, "mytestbucket", minio.ListObjectsOptions{Prefix: "starthere", Recursive:true}) {
-// fmt.Println(object)
-// }
-//
+// api := client.New(....)
+// for object := range api.ListObjects(ctx, "mytestbucket", minio.ListObjectsOptions{Prefix: "starthere", Recursive:true}) {
+// fmt.Println(object)
+// }
func (c *Client) ListObjects(ctx context.Context, bucketName string, opts ListObjectsOptions) <-chan ObjectInfo {
if opts.WithVersions {
return c.listObjectVersions(ctx, bucketName, opts)
@@ -694,12 +722,12 @@ func (c *Client) ListObjects(ctx context.Context, bucketName string, opts ListOb
// If you enable recursive as 'true' this function will return back all
// the multipart objects in a given bucket name.
//
-// api := client.New(....)
-// // Recurively list all objects in 'mytestbucket'
-// recursive := true
-// for message := range api.ListIncompleteUploads(context.Background(), "mytestbucket", "starthere", recursive) {
-// fmt.Println(message)
-// }
+// api := client.New(....)
+// // Recurively list all objects in 'mytestbucket'
+// recursive := true
+// for message := range api.ListIncompleteUploads(context.Background(), "mytestbucket", "starthere", recursive) {
+// fmt.Println(message)
+// }
func (c *Client) ListIncompleteUploads(ctx context.Context, bucketName, objectPrefix string, recursive bool) <-chan ObjectMultipartInfo {
return c.listIncompleteUploads(ctx, bucketName, objectPrefix, recursive)
}
@@ -916,7 +944,7 @@ func (c *Client) findUploadIDs(ctx context.Context, bucketName, objectName strin
}
// listObjectPartsQuery (List Parts query)
-// - lists some or all (up to 1000) parts that have been uploaded
+// - lists some or all (up to 1000) parts that have been uploaded
// for a specific multipart upload
//
// You can use the request parameters as selection criteria to return