Skip to content

Commit

Permalink
Fix ListStorageSpaces for ocm
Browse files Browse the repository at this point in the history
Currently there are no mountpoints for federated shares. We just return
an empty list on the ListStorageSpaces request.

Related: owncloud/ocis#10689
  • Loading branch information
rhafer committed Dec 3, 2024
1 parent 17f3395 commit 1cf4e6c
Showing 1 changed file with 2 additions and 81 deletions.
83 changes: 2 additions & 81 deletions pkg/ocm/storage/received/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1cf4e6c

Please sign in to comment.