Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gateway dumb again #2394

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/remove-gateway-logic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Remove gateway logic

Removed logic in gateway that cares about absolute paths. From now on clients are responsible for converting
pathes to id based requests.

https://github.com/cs3org/reva/pull/2394
33 changes: 23 additions & 10 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"fmt"
"path"
"strings"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
Expand All @@ -30,6 +31,7 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/utils"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -349,7 +351,8 @@ func (s *svc) createOCMReference(ctx context.Context, share *ocm.Share) (*rpc.St

log.Info().Msg("mount path will be:" + refPath)

c, p, err := s.findByPath(ctx, refPath)
// FIXME: Do I need to use absolute paths?
c, p, err := s.find(ctx, &provider.Reference{Path: refPath})
if err != nil {
log.Error().Err(err).Msg("createOCMReference: could not find storage provider")
if _, ok := err.(errtypes.IsNotFound); ok {
Expand All @@ -358,17 +361,27 @@ func (s *svc) createOCMReference(ctx context.Context, share *ocm.Share) (*rpc.St
return status.NewInternal(ctx, "error finding storage provider"), nil
}

var (
root *provider.ResourceId
mountPath string
)
for _, space := range decodeSpaces(p) {
mountPath = decodePath(space)
root = space.Root
break // TODO can there be more than one space for a path?
spaceID := ""
mountPath := p.ProviderPath

spacePaths := decodeSpacePaths(p)
if len(spacePaths) == 0 {
spacePaths[""] = mountPath
}

var pRef *provider.Reference
for spaceID, mountPath = range spacePaths {
rootSpace, rootNode, _ := utils.SplitStorageSpaceID(spaceID)
pRef = &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: rootSpace,
OpaqueId: rootNode,
},
Path: utils.MakeRelativePath(strings.TrimPrefix(refPath, mountPath)),
}
break
}

pRef := unwrap(&provider.Reference{Path: refPath}, mountPath, root)
createRefReq := &provider.CreateReferenceRequest{
Ref: pRef,
TargetUri: targetURI,
Expand Down
Loading