Optimized List objects v2 for metadata (#1175)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2021-11-01 18:34:20 -07:00
committed by GitHub
parent dfd0d084d9
commit 2f917134e6
5 changed files with 28 additions and 35 deletions

View File

@@ -96,9 +96,6 @@ func setBucketQuota(ctx context.Context, ac *AdminClient, bucket *string, bucket
}
func getBucketQuotaResponse(session *models.Principal, params user_api.GetBucketQuotaParams) (*models.BucketQuota, *models.Error) {
if !isErasureBackend() {
return &models.BucketQuota{}, nil
}
mAdmin, err := NewMinioAdminClient(session)
if err != nil {

View File

@@ -22,10 +22,8 @@ import (
"encoding/json"
"fmt"
"strings"
"sync"
"time"
"github.com/minio/madmin-go"
"github.com/minio/mc/cmd"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7"
@@ -202,10 +200,6 @@ func setBucketVersioningResponse(session *models.Principal, bucketName string, p
}
func getBucketReplicationResponse(session *models.Principal, bucketName string) (*models.BucketReplicationResponse, error) {
if !isErasureBackend() {
return &models.BucketReplicationResponse{}, nil
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
@@ -256,12 +250,6 @@ func getBucketReplicationResponse(session *models.Principal, bucketName string)
}
func getBucketVersionedResponse(session *models.Principal, bucketName string) (*models.BucketVersioningResponse, error) {
if !isErasureBackend() {
return &models.BucketVersioningResponse{
IsVersioned: false,
}, nil
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
@@ -288,13 +276,6 @@ func getBucketVersionedResponse(session *models.Principal, bucketName string) (*
return bucketVResponse, nil
}
var serverBackendType madmin.BackendType
var serverBackendOnce sync.Once
func isErasureBackend() bool {
return serverBackendType == madmin.Erasure
}
// getAccountInfo fetches a list of all buckets allowed to that particular client from MinIO Servers
func getAccountInfo(ctx context.Context, client MinioAdmin) ([]*models.Bucket, error) {
info, err := client.AccountInfo(ctx)
@@ -302,10 +283,6 @@ func getAccountInfo(ctx context.Context, client MinioAdmin) ([]*models.Bucket, e
return []*models.Bucket{}, err
}
serverBackendOnce.Do(func() {
serverBackendType = info.Server.Type
})
var bucketInfos []*models.Bucket
for _, bucket := range info.Buckets {

View File

@@ -197,7 +197,7 @@ func getListObjectsResponse(session *models.Principal, params user_api.ListObjec
if params.Recursive != nil {
recursive = *params.Recursive
}
if isErasureBackend() && params.WithVersions != nil {
if params.WithVersions != nil {
withVersions = *params.WithVersions
}
if params.WithMetadata != nil {
@@ -230,7 +230,16 @@ func getListObjectsResponse(session *models.Principal, params user_api.ListObjec
// listBucketObjects gets an array of objects in a bucket
func listBucketObjects(ctx context.Context, client MinioClient, bucketName string, prefix string, recursive, withVersions bool, withMetadata bool) ([]*models.BucketObject, error) {
var objects []*models.BucketObject
for lsObj := range client.listObjects(ctx, bucketName, minio.ListObjectsOptions{Prefix: prefix, Recursive: recursive, WithVersions: withVersions, WithMetadata: withMetadata}) {
opts := minio.ListObjectsOptions{
Prefix: prefix,
Recursive: recursive,
WithVersions: withVersions,
WithMetadata: withMetadata,
}
if withMetadata {
opts.MaxKeys = 1
}
for lsObj := range client.listObjects(ctx, bucketName, opts) {
if lsObj.Err != nil {
return nil, lsObj.Err
}