Skip to content

Commit

Permalink
feat(storage): support IncludeFoldersAsPrefixes for gRPC (#10767)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shubham-diwakar authored Aug 26, 2024
1 parent ec0cbb2 commit 65bcc59
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
6 changes: 1 addition & 5 deletions storage/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 65bcc59

Please sign in to comment.