Skip to content

Commit 65bcc59

Browse files
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.
1 parent ec0cbb2 commit 65bcc59

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

storage/grpc_client.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,12 @@ func (c *grpcStorageClient) ListObjects(ctx context.Context, bucket string, q *Q
432432
MatchGlob: it.query.MatchGlob,
433433
ReadMask: q.toFieldMask(), // a nil Query still results in a "*" FieldMask
434434
SoftDeleted: it.query.SoftDeleted,
435+
IncludeFoldersAsPrefixes: it.query.IncludeFoldersAsPrefixes,
435436
}
436437
if s.userProject != "" {
437438
ctx = setUserProjectMetadata(ctx, s.userProject)
438439
}
439440
fetch := func(pageSize int, pageToken string) (token string, err error) {
440-
// IncludeFoldersAsPrefixes is not supported for gRPC
441-
// TODO: remove this when support is added in the proto.
442-
if it.query.IncludeFoldersAsPrefixes {
443-
return "", status.Errorf(codes.Unimplemented, "storage: IncludeFoldersAsPrefixes is not supported in gRPC")
444-
}
445441
var objects []*storagepb.Object
446442
var gitr *gapic.ObjectIterator
447443
err = run(it.ctx, func(ctx context.Context) error {

storage/integration_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,7 @@ func TestIntegration_ObjectIterationMatchGlob(t *testing.T) {
14921492
}
14931493

14941494
func TestIntegration_ObjectIterationManagedFolder(t *testing.T) {
1495-
ctx := skipGRPC("not yet implemented in gRPC")
1496-
multiTransportTest(skipJSONReads(ctx, "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) {
1495+
multiTransportTest(skipJSONReads(context.Background(), "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) {
14971496
newBucketName := prefix + uidSpace.New()
14981497
h := testHelper{t}
14991498
bkt := client.Bucket(newBucketName).Retryer(WithPolicy(RetryAlways))

storage/storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,6 @@ type Query struct {
16951695

16961696
// IncludeFoldersAsPrefixes includes Folders and Managed Folders in the set of
16971697
// prefixes returned by the query. Only applicable if Delimiter is set to /.
1698-
// IncludeFoldersAsPrefixes is not yet implemented in the gRPC API.
16991698
IncludeFoldersAsPrefixes bool
17001699

17011700
// SoftDeleted indicates whether to list soft-deleted objects.

0 commit comments

Comments
 (0)