From 65bcc59a6c0753f8fbd66c8792bc69300e95ec62 Mon Sep 17 00:00:00 2001 From: shubham-diwakar Date: Mon, 26 Aug 2024 19:00:21 +0530 Subject: [PATCH] feat(storage): support IncludeFoldersAsPrefixes for gRPC (#10767) Adds support for IncludeFoldersAsPrefixes to object listing for gRPC protocol, which allows managed folders to be included in the results. For http protocol it was added in #9211. --- storage/grpc_client.go | 6 +----- storage/integration_test.go | 3 +-- storage/storage.go | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/storage/grpc_client.go b/storage/grpc_client.go index 47cca12e4882..24432e58904d 100644 --- a/storage/grpc_client.go +++ b/storage/grpc_client.go @@ -432,16 +432,12 @@ func (c *grpcStorageClient) ListObjects(ctx context.Context, bucket string, q *Q MatchGlob: it.query.MatchGlob, ReadMask: q.toFieldMask(), // a nil Query still results in a "*" FieldMask SoftDeleted: it.query.SoftDeleted, + IncludeFoldersAsPrefixes: it.query.IncludeFoldersAsPrefixes, } if s.userProject != "" { ctx = setUserProjectMetadata(ctx, s.userProject) } fetch := func(pageSize int, pageToken string) (token string, err error) { - // IncludeFoldersAsPrefixes is not supported for gRPC - // TODO: remove this when support is added in the proto. - if it.query.IncludeFoldersAsPrefixes { - return "", status.Errorf(codes.Unimplemented, "storage: IncludeFoldersAsPrefixes is not supported in gRPC") - } var objects []*storagepb.Object var gitr *gapic.ObjectIterator err = run(it.ctx, func(ctx context.Context) error { diff --git a/storage/integration_test.go b/storage/integration_test.go index aa3dd8b73088..3ab4d588c064 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -1492,8 +1492,7 @@ func TestIntegration_ObjectIterationMatchGlob(t *testing.T) { } func TestIntegration_ObjectIterationManagedFolder(t *testing.T) { - ctx := skipGRPC("not yet implemented in gRPC") - multiTransportTest(skipJSONReads(ctx, "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) { + multiTransportTest(skipJSONReads(context.Background(), "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) { newBucketName := prefix + uidSpace.New() h := testHelper{t} bkt := client.Bucket(newBucketName).Retryer(WithPolicy(RetryAlways)) diff --git a/storage/storage.go b/storage/storage.go index b6316fa668f9..f3229d0d1a37 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -1695,7 +1695,6 @@ type Query struct { // IncludeFoldersAsPrefixes includes Folders and Managed Folders in the set of // prefixes returned by the query. Only applicable if Delimiter is set to /. - // IncludeFoldersAsPrefixes is not yet implemented in the gRPC API. IncludeFoldersAsPrefixes bool // SoftDeleted indicates whether to list soft-deleted objects.