From 1cf4e6c72a5da1e6234fc3fc58a6fd6d447428e6 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 3 Dec 2024 12:52:51 +0100 Subject: [PATCH] Fix ListStorageSpaces for ocm Currently there are no mountpoints for federated shares. We just return an empty list on the ListStorageSpaces request. Related: https://github.com/owncloud/ocis/issues/10689 --- pkg/ocm/storage/received/ocm.go | 83 +-------------------------------- 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/pkg/ocm/storage/received/ocm.go b/pkg/ocm/storage/received/ocm.go index c76fe8141a..5a80502a51 100644 --- a/pkg/ocm/storage/received/ocm.go +++ b/pkg/ocm/storage/received/ocm.go @@ -29,11 +29,9 @@ import ( "net/url" "path/filepath" "regexp" - "strings" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" - userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" ocmpb "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -49,7 +47,6 @@ import ( "github.com/cs3org/reva/v2/pkg/sharedconf" "github.com/cs3org/reva/v2/pkg/storage" "github.com/cs3org/reva/v2/pkg/storage/fs/registry" - "github.com/cs3org/reva/v2/pkg/storagespace" "github.com/cs3org/reva/v2/pkg/utils" "github.com/cs3org/reva/v2/pkg/utils/cfg" ) @@ -492,84 +489,8 @@ func (d *driver) Unlock(ctx context.Context, ref *provider.Reference, lock *prov } func (d *driver) ListStorageSpaces(ctx context.Context, filters []*provider.ListStorageSpacesRequest_Filter, _ bool) ([]*provider.StorageSpace, error) { - spaceTypes := map[string]struct{}{} - var exists = struct{}{} - appendTypes := []string{} - for _, f := range filters { - if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_SPACE_TYPE { - spaceType := f.GetSpaceType() - if spaceType == "+mountpoint" { - appendTypes = append(appendTypes, strings.TrimPrefix(spaceType, "+")) - continue - } - spaceTypes[spaceType] = exists - } - } - - lrsRes, err := d.gateway.ListReceivedOCMShares(ctx, &ocmpb.ListReceivedOCMSharesRequest{}) - if err != nil { - return nil, err - } - // FIXME This might have to be ListOCMShares - // these are grants - - lsRes, err := d.gateway.ListOCMShares(ctx, &ocmpb.ListOCMSharesRequest{}) - if err != nil { - return nil, err - } - - if len(spaceTypes) == 0 { - spaceTypes["mountpoint"] = exists - } - for _, s := range appendTypes { - spaceTypes[s] = exists - } - - spaces := []*provider.StorageSpace{} - for k := range spaceTypes { - if k == "mountpoint" { - for _, share := range lrsRes.Shares { - root := &provider.ResourceId{ - StorageId: utils.OCMStorageProviderID, - SpaceId: share.Id.OpaqueId, - OpaqueId: share.Id.OpaqueId, - } - space := &provider.StorageSpace{ - Id: &provider.StorageSpaceId{ - OpaqueId: storagespace.FormatResourceID(root), - }, - SpaceType: "mountpoint", - Owner: &userv1beta1.User{ - Id: share.Grantee.GetUserId(), - }, - Root: root, - } - - spaces = append(spaces, space) - } - for _, share := range lsRes.Shares { - root := &provider.ResourceId{ - StorageId: utils.OCMStorageProviderID, - SpaceId: share.Id.OpaqueId, - OpaqueId: share.Id.OpaqueId, - } - space := &provider.StorageSpace{ - Id: &provider.StorageSpaceId{ - OpaqueId: storagespace.FormatResourceID(root), - }, - SpaceType: "mountpoint", - Owner: &userv1beta1.User{ - Id: share.Grantee.GetUserId(), - }, - Root: root, - } - - spaces = append(spaces, space) - } - } - } - - return spaces, nil + // ocm doesn't create any mountpoints, so there are not spaces to return here + return []*provider.StorageSpace{}, nil } func (d *driver) CreateStorageSpace(ctx context.Context, req *provider.CreateStorageSpaceRequest) (*provider.CreateStorageSpaceResponse, error) {