diff --git a/Makefile b/Makefile
index 8f97b63305e..a34f8a418ee 100644
--- a/Makefile
+++ b/Makefile
@@ -58,8 +58,8 @@ test-integration: build-ci
# This is needed for osx because this os does not support static linking
# Use the build target without the static flag
-test-integration-osx: build
- cd tests/integration && go test -race ./...
+test-integration-osx: off build
+ cd tests/integration && go test -race -v ./...
litmus-test-old: build
cd tests/oc-integration-tests/local && ../../../cmd/revad/revad -c frontend.toml &
diff --git a/changelog/unreleased/space-id.md b/changelog/unreleased/space-id.md
new file mode 100644
index 00000000000..5992f6eebee
--- /dev/null
+++ b/changelog/unreleased/space-id.md
@@ -0,0 +1,5 @@
+Change: Use spaceID on the cs3api
+
+We introduced a new spaceID field on the cs3api to implement the spaces feature in a cleaner way.
+
+https://github.com/cs3org/reva/pull/3006
diff --git a/cmd/reva/upload.go b/cmd/reva/upload.go
index 0967798806d..a2c4d4efd68 100644
--- a/cmd/reva/upload.go
+++ b/cmd/reva/upload.go
@@ -218,7 +218,7 @@ func uploadCommand() *command {
info := res2.Info
- fmt.Printf("File uploaded: %s:%s %d %s\n", info.Id.StorageId, info.Id.OpaqueId, info.Size, info.Path)
+ fmt.Printf("File uploaded: %s %d %s\n", info.Id, info.Size, info.Path)
return nil
}
diff --git a/internal/grpc/services/gateway/storageprovider.go b/internal/grpc/services/gateway/storageprovider.go
index 23dfa13e9cd..311957995f7 100644
--- a/internal/grpc/services/gateway/storageprovider.go
+++ b/internal/grpc/services/gateway/storageprovider.go
@@ -231,11 +231,11 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
for _, f := range req.Filters {
switch f.Type {
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- sid, oid, err := storagespace.SplitID(f.GetId().OpaqueId)
+ sid, spid, oid, err := storagespace.SplitID(f.GetId().OpaqueId)
if err != nil {
continue
}
- filters["storage_id"], filters["opaque_id"] = sid, oid
+ filters["storage_id"], filters["space_id"], filters["opaque_id"] = sid, spid, oid
case provider.ListStorageSpacesRequest_Filter_TYPE_OWNER:
filters["owner_idp"] = f.GetOwner().Idp
filters["owner_id"] = f.GetOwner().OpaqueId
@@ -318,17 +318,14 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
_, purge = opaque.Map["purge"]
}
- storageid, opaqeid, err := storagespace.SplitID(req.Id.OpaqueId)
+ rid, err := storagespace.ParseID(req.Id.OpaqueId)
if err != nil {
return &provider.DeleteStorageSpaceResponse{
- Status: status.NewStatusFromErrType(ctx, fmt.Sprintf("gateway could not split space id %s", req.GetId().GetOpaqueId()), err),
+ Status: status.NewStatusFromErrType(ctx, fmt.Sprintf("gateway could not parse space id %s", req.GetId().GetOpaqueId()), err),
}, nil
}
- ref := &provider.Reference{ResourceId: &provider.ResourceId{
- StorageId: storageid,
- OpaqueId: opaqeid,
- }}
+ ref := &provider.Reference{ResourceId: &rid}
c, _, err := s.find(ctx, ref)
if err != nil {
return &provider.DeleteStorageSpaceResponse{
@@ -359,7 +356,7 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
log.Debug().Msg("purging storage space")
// List all shares in this storage space
lsRes, err := s.ListShares(ctx, &collaborationv1beta1.ListSharesRequest{
- Filters: []*collaborationv1beta1.Filter{share.StorageIDFilter(storageid)},
+ Filters: []*collaborationv1beta1.Filter{share.StorageIDFilter(id.SpaceId)}, // FIXME rename the filter? @c0rby
})
switch {
case err != nil:
@@ -384,7 +381,7 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
// List all public shares in this storage space
lpsRes, err := s.ListPublicShares(ctx, &linkv1beta1.ListPublicSharesRequest{
- Filters: []*linkv1beta1.ListPublicSharesRequest_Filter{publicshare.StorageIDFilter(storageid)},
+ Filters: []*linkv1beta1.ListPublicSharesRequest_Filter{publicshare.StorageIDFilter(id.SpaceId)}, // FIXME rename the filter? @c0rby
})
switch {
case err != nil:
@@ -1102,7 +1099,9 @@ func (s *svc) findSpaces(ctx context.Context, ref *provider.Reference) ([]*regis
case ref == nil:
return nil, errtypes.BadRequest("missing reference")
case ref.ResourceId != nil:
- // no action needed in that case
+ if ref.ResourceId.OpaqueId == "" {
+ ref.ResourceId.OpaqueId = ref.ResourceId.SpaceId
+ }
case ref.Path != "": // TODO implement a mount path cache in the registry?
// nothing to do here either
default:
@@ -1115,6 +1114,7 @@ func (s *svc) findSpaces(ctx context.Context, ref *provider.Reference) ([]*regis
}
if ref.ResourceId != nil {
filters["storage_id"] = ref.ResourceId.StorageId
+ filters["space_id"] = ref.ResourceId.SpaceId
filters["opaque_id"] = ref.ResourceId.OpaqueId
}
@@ -1132,7 +1132,9 @@ func (s *svc) findSingleSpace(ctx context.Context, ref *provider.Reference) ([]*
case ref == nil:
return nil, errtypes.BadRequest("missing reference")
case ref.ResourceId != nil:
- // no action needed in that case
+ if ref.ResourceId.OpaqueId == "" {
+ ref.ResourceId.OpaqueId = ref.ResourceId.SpaceId
+ }
case ref.Path != "": // TODO implement a mount path cache in the registry?
// nothing to do here either
default:
@@ -1146,6 +1148,7 @@ func (s *svc) findSingleSpace(ctx context.Context, ref *provider.Reference) ([]*
}
if ref.ResourceId != nil {
filters["storage_id"] = ref.ResourceId.StorageId
+ filters["space_id"] = ref.ResourceId.SpaceId
filters["opaque_id"] = ref.ResourceId.OpaqueId
}
@@ -1208,6 +1211,7 @@ func unwrap(ref *provider.Reference, mountPoint string, root *provider.ResourceI
return &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: ref.ResourceId.StorageId,
+ SpaceId: ref.ResourceId.SpaceId,
OpaqueId: ref.ResourceId.OpaqueId,
},
Path: ref.Path,
diff --git a/internal/grpc/services/gateway/storageprovidercache.go b/internal/grpc/services/gateway/storageprovidercache.go
index 978006fd324..76e121fbd67 100644
--- a/internal/grpc/services/gateway/storageprovidercache.go
+++ b/internal/grpc/services/gateway/storageprovidercache.go
@@ -105,7 +105,7 @@ func (c Caches) RemoveStat(user *userpb.User, res *provider.ResourceId) {
sid := ""
oid := ""
if res != nil {
- sid = "sid:" + res.StorageId
+ sid = "sid:" + res.SpaceId
oid = "oid:" + res.OpaqueId
}
@@ -133,7 +133,7 @@ func (c Caches) RemoveListStorageProviders(res *provider.ResourceId) {
if res == nil {
return
}
- sid := res.StorageId
+ sid := res.SpaceId
cache := c[listproviders]
for _, key := range cache.GetKeys() {
@@ -182,9 +182,9 @@ func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *reg
user := ctxpkg.ContextMustGetUser(ctx)
- storageID := sdk.DecodeOpaqueMap(in.Opaque)["storage_id"]
+ spaceID := sdk.DecodeOpaqueMap(in.Opaque)["space_id"]
- key := user.GetId().GetOpaqueId() + "!" + storageID
+ key := user.GetId().GetOpaqueId() + "!" + spaceID
if key != "!" {
s := ®istry.ListStorageProvidersResponse{}
if err := pullFromCache(cache, key, s); err == nil {
@@ -198,9 +198,9 @@ func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *reg
return nil, err
case resp.Status.Code != rpc.Code_CODE_OK:
return resp, nil
- case storageID == "":
+ case spaceID == "":
return resp, nil
- case storageID == utils.ShareStorageProviderID: // TODO do we need to compare providerid and spaceid separately?
+ case spaceID == utils.ShareStorageSpaceID: // TODO do we need to compare providerid and spaceid separately?
return resp, nil
default:
return resp, pushToCache(cache, key, resp)
@@ -230,7 +230,7 @@ type cachedAPIClient struct {
// a key looks like: uid:1234-1233!sid:5678-5677!oid:9923-9934!path:/path/to/source
// as you see it adds "uid:"/"sid:"/"oid:" prefixes to the uuids so they can be differentiated
func statKey(user *userpb.User, ref *provider.Reference, metaDataKeys, fieldMaskPaths []string) string {
- if ref == nil || ref.ResourceId == nil || ref.ResourceId.StorageId == "" {
+ if ref == nil || ref.ResourceId == nil || ref.ResourceId.SpaceId == "" {
return ""
}
@@ -238,7 +238,7 @@ func statKey(user *userpb.User, ref *provider.Reference, metaDataKeys, fieldMask
key.WriteString("uid:")
key.WriteString(user.Id.OpaqueId)
key.WriteString("!sid:")
- key.WriteString(ref.ResourceId.StorageId)
+ key.WriteString(ref.ResourceId.SpaceId)
key.WriteString("!oid:")
key.WriteString(ref.ResourceId.OpaqueId)
key.WriteString("!path:")
diff --git a/internal/grpc/services/gateway/usershareprovider.go b/internal/grpc/services/gateway/usershareprovider.go
index 43aaad35de9..872840482bf 100644
--- a/internal/grpc/services/gateway/usershareprovider.go
+++ b/internal/grpc/services/gateway/usershareprovider.go
@@ -32,7 +32,6 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/storage/utils/grants"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/pkg/errors"
)
@@ -717,11 +716,11 @@ func refIsSpaceRoot(ref *provider.ResourceId) bool {
if ref == nil {
return false
}
- if ref.StorageId == "" || ref.OpaqueId == "" {
+ if ref.SpaceId == "" || ref.OpaqueId == "" {
return false
}
- _, sid := storagespace.SplitStorageID(ref.GetStorageId())
- return sid == ref.OpaqueId
+
+ return ref.SpaceId == ref.OpaqueId
}
func shareIsSpaceRoot(key *collaboration.ShareKey) bool {
diff --git a/internal/grpc/services/publicstorageprovider/publicstorageprovider.go b/internal/grpc/services/publicstorageprovider/publicstorageprovider.go
index e1fb1b66603..6ce279fb737 100644
--- a/internal/grpc/services/publicstorageprovider/publicstorageprovider.go
+++ b/internal/grpc/services/publicstorageprovider/publicstorageprovider.go
@@ -105,10 +105,6 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
}
func (s *service) SetArbitraryMetadata(ctx context.Context, req *provider.SetArbitraryMetadataRequest) (*provider.SetArbitraryMetadataResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -127,10 +123,6 @@ func (s *service) UnsetArbitraryMetadata(ctx context.Context, req *provider.Unse
// SetLock puts a lock on the given reference
func (s *service) SetLock(ctx context.Context, req *provider.SetLockRequest) (*provider.SetLockResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -145,10 +137,6 @@ func (s *service) SetLock(ctx context.Context, req *provider.SetLockRequest) (*p
// GetLock returns an existing lock on the given reference
func (s *service) GetLock(ctx context.Context, req *provider.GetLockRequest) (*provider.GetLockResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -163,10 +151,6 @@ func (s *service) GetLock(ctx context.Context, req *provider.GetLockRequest) (*p
// RefreshLock refreshes an existing lock on the given reference
func (s *service) RefreshLock(ctx context.Context, req *provider.RefreshLockRequest) (*provider.RefreshLockResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -181,10 +165,6 @@ func (s *service) RefreshLock(ctx context.Context, req *provider.RefreshLockRequ
// Unlock removes an existing lock from the given reference
func (s *service) Unlock(ctx context.Context, req *provider.UnlockRequest) (*provider.UnlockResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -198,10 +178,6 @@ func (s *service) Unlock(ctx context.Context, req *provider.UnlockRequest) (*pro
}
func (s *service) InitiateFileDownload(ctx context.Context, req *provider.InitiateFileDownloadRequest) (*provider.InitiateFileDownloadResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
statReq := &provider.StatRequest{Ref: req.Ref}
statRes, err := s.Stat(ctx, statReq)
if err != nil {
@@ -325,10 +301,6 @@ func (s *service) initiateFileDownload(ctx context.Context, req *provider.Initia
}
func (s *service) InitiateFileUpload(ctx context.Context, req *provider.InitiateFileUploadRequest) (*provider.InitiateFileUploadResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
cs3Ref, _, ls, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -413,14 +385,6 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt
// so id based requests can find the correct storage provider. These spaces
// have their root set to the shared resource.
func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) {
- for i, f := range req.Filters {
- if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID {
- _, id := storagespace.SplitStorageID(f.GetId().GetOpaqueId())
- req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Id{Id: &provider.StorageSpaceId{OpaqueId: id}}
- break
- }
- }
-
spaceTypes := map[string]struct{}{}
var exists = struct{}{}
appendTypes := []string{}
@@ -435,17 +399,19 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
}
spaceTypes[spaceType] = exists
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- spaceid, shareid, err := storagespace.SplitID(f.GetId().OpaqueId)
+ resID, err := storagespace.ParseID(f.GetId().GetOpaqueId())
if err != nil {
- continue
+ return &provider.ListStorageSpacesResponse{
+ Status: &rpc.Status{Code: rpc.Code_CODE_INVALID_ARGUMENT, Message: err.Error()},
+ }, nil
}
- if spaceid != utils.PublicStorageProviderID {
+ if resID.SpaceId != utils.PublicStorageSpaceID {
return &provider.ListStorageSpacesResponse{
// a specific id was requested, return not found instead of empty list
Status: &rpc.Status{Code: rpc.Code_CODE_NOT_FOUND},
}, nil
}
- spaceID = &provider.ResourceId{StorageId: spaceid, OpaqueId: shareid}
+ spaceID = &resID
}
}
@@ -480,7 +446,7 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
// we know a grant for this resource
space := &provider.StorageSpace{
Id: &provider.StorageSpaceId{
- OpaqueId: root.StorageId + "!" + root.OpaqueId,
+ OpaqueId: storagespace.FormatResourceID(*root),
},
SpaceType: "grant",
Owner: &userv1beta1.User{Id: share.Owner},
@@ -508,7 +474,7 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
}
space := &provider.StorageSpace{
Id: &provider.StorageSpaceId{
- OpaqueId: root.StorageId + "!" + root.OpaqueId,
+ OpaqueId: storagespace.FormatResourceID(*root),
},
SpaceType: "mountpoint",
Owner: &userv1beta1.User{Id: share.Owner}, // FIXME actually, the mount point belongs to no one?
@@ -552,10 +518,6 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
}
func (s *service) CreateContainer(ctx context.Context, req *provider.CreateContainerRequest) (*provider.CreateContainerResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "CreateContainer")
defer span.End()
@@ -596,10 +558,6 @@ func (s *service) CreateContainer(ctx context.Context, req *provider.CreateConta
}
func (s *service) TouchFile(ctx context.Context, req *provider.TouchFileRequest) (*provider.TouchFileResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref)
switch {
case err != nil:
@@ -613,10 +571,6 @@ func (s *service) TouchFile(ctx context.Context, req *provider.TouchFileRequest)
}
func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*provider.DeleteResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Delete")
defer span.End()
@@ -657,13 +611,6 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
}
func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provider.MoveResponse, error) {
- if req.Source.GetResourceId() != nil {
- _, req.Source.ResourceId.StorageId = storagespace.SplitStorageID(req.Source.ResourceId.StorageId)
- }
- if req.Destination.GetResourceId() != nil {
- _, req.Destination.ResourceId.StorageId = storagespace.SplitStorageID(req.Destination.ResourceId.StorageId)
- }
-
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Move")
defer span.End()
@@ -727,10 +674,6 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide
}
func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Stat")
defer span.End()
@@ -828,9 +771,6 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest,
}
func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
share, ok := extractLinkFromScope(ctx)
if !ok {
diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go
index ef108120e37..56b20478c33 100644
--- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go
+++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go
@@ -105,10 +105,6 @@ func New(gateway gateway.GatewayAPIClient, c collaboration.CollaborationAPIClien
}
func (s *service) SetArbitraryMetadata(ctx context.Context, req *provider.SetArbitraryMetadataRequest) (*provider.SetArbitraryMetadataResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -131,10 +127,6 @@ func (s *service) SetArbitraryMetadata(ctx context.Context, req *provider.SetArb
}
func (s *service) UnsetArbitraryMetadata(ctx context.Context, req *provider.UnsetArbitraryMetadataRequest) (*provider.UnsetArbitraryMetadataResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -157,10 +149,6 @@ func (s *service) UnsetArbitraryMetadata(ctx context.Context, req *provider.Unse
}
func (s *service) InitiateFileDownload(ctx context.Context, req *provider.InitiateFileDownloadRequest) (*provider.InitiateFileDownloadResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -213,10 +201,6 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia
}
func (s *service) InitiateFileUpload(ctx context.Context, req *provider.InitiateFileUploadRequest) (*provider.InitiateFileUploadResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -314,14 +298,6 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt
// should be found.
func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) {
- for i, f := range req.Filters {
- if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID {
- _, id := storagespace.SplitStorageID(f.GetId().GetOpaqueId())
- req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Id{Id: &provider.StorageSpaceId{OpaqueId: id}}
- break
- }
- }
-
spaceTypes := map[string]struct{}{}
var exists = struct{}{}
var fetchShares bool
@@ -342,18 +318,18 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
}
spaceTypes[spaceType] = exists
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- spaceid, shareid, err := storagespace.SplitID(f.GetId().OpaqueId)
+ storageid, spaceid, shareid, err := storagespace.SplitID(f.GetId().OpaqueId)
if err != nil {
continue
}
- if spaceid != utils.ShareStorageProviderID {
+ if spaceid != utils.ShareStorageSpaceID {
return &provider.ListStorageSpacesResponse{
// a specific id was requested, return not found instead of empty list
Status: &rpc.Status{Code: rpc.Code_CODE_NOT_FOUND},
}, nil
}
- spaceID = &provider.ResourceId{StorageId: spaceid, OpaqueId: shareid}
+ spaceID = &provider.ResourceId{StorageId: storageid, SpaceId: spaceid, OpaqueId: shareid}
}
}
@@ -384,8 +360,9 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
switch k {
case "virtual":
virtualRootID := &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID),
- OpaqueId: utils.ShareStorageProviderID,
+ StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
+ OpaqueId: utils.ShareStorageSpaceID,
}
if spaceID == nil || isShareJailRoot(spaceID) {
earliestShare, atLeastOneAccepted := findEarliestShare(receivedShares, shareInfo)
@@ -444,6 +421,7 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
}
root := &provider.ResourceId{
StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: receivedShare.Share.Id.OpaqueId,
}
// do we filter by id
@@ -467,12 +445,13 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
// add the resourceID for the grant
if receivedShare.Share.ResourceId != nil {
opaque = utils.AppendPlainToOpaque(opaque, "grantStorageID", receivedShare.Share.ResourceId.StorageId)
+ opaque = utils.AppendPlainToOpaque(opaque, "grantSpaceID", receivedShare.Share.ResourceId.SpaceId)
opaque = utils.AppendPlainToOpaque(opaque, "grantOpaqueID", receivedShare.Share.ResourceId.OpaqueId)
}
// prefix storageid if we are responsible
- if root.StorageId == utils.ShareStorageSpaceID {
- root.StorageId = storagespace.FormatStorageID(utils.ShareStorageProviderID, root.StorageId)
+ if root.SpaceId == utils.ShareStorageSpaceID {
+ root.StorageId = utils.ShareStorageProviderID
}
space := &provider.StorageSpace{
@@ -511,10 +490,6 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
}
func (s *service) CreateContainer(ctx context.Context, req *provider.CreateContainerRequest) (*provider.CreateContainerResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -536,10 +511,6 @@ func (s *service) CreateContainer(ctx context.Context, req *provider.CreateConta
}
func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*provider.DeleteResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -556,7 +527,7 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
}
// the root of a share always has the path "."
- if req.Ref.ResourceId.StorageId == utils.ShareStorageProviderID && req.Ref.Path == "." {
+ if req.Ref.ResourceId.StorageId == utils.ShareStorageProviderID && req.Ref.ResourceId.SpaceId == utils.ShareStorageSpaceID && req.Ref.Path == "." {
err := s.rejectReceivedShare(ctx, receivedShare)
if err != nil {
return &provider.DeleteResponse{
@@ -575,13 +546,6 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
}
func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provider.MoveResponse, error) {
- if req.Source.GetResourceId() != nil {
- _, req.Source.ResourceId.StorageId = storagespace.SplitStorageID(req.Source.ResourceId.StorageId)
- }
- if req.Destination.GetResourceId() != nil {
- _, req.Destination.ResourceId.StorageId = storagespace.SplitStorageID(req.Destination.ResourceId.StorageId)
- }
-
appctx.GetLogger(ctx).Debug().
Interface("source", req.Source).
Interface("destination", req.Destination).
@@ -634,7 +598,7 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide
Status: rpcStatus,
}, nil
}
- if srcReceivedShare.Share.ResourceId.StorageId != dstReceivedShare.Share.ResourceId.StorageId {
+ if srcReceivedShare.Share.ResourceId.SpaceId != dstReceivedShare.Share.ResourceId.SpaceId {
return &provider.MoveResponse{
Status: status.NewInvalid(ctx, "sharesstorageprovider: can not move between shares on different storages"),
}, nil
@@ -668,10 +632,6 @@ func (s *service) Unlock(ctx context.Context, req *provider.UnlockRequest) (*pro
}
func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
if isVirtualRoot(req.Ref) {
owner, ok := ctxpkg.ContextGetUser(ctx)
if !ok {
@@ -752,10 +712,6 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest,
return gstatus.Errorf(codes.Unimplemented, "method not implemented")
}
func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
if isVirtualRoot(req.Ref) {
// The root is empty, it is filled by mountpoints
// so, when accessing the root via /dav/spaces, we need to list the accepted shares with their mountpoint
@@ -831,10 +787,6 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer
})
}
func (s *service) ListFileVersions(ctx context.Context, req *provider.ListFileVersionsRequest) (*provider.ListFileVersionsResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -857,10 +809,6 @@ func (s *service) ListFileVersions(ctx context.Context, req *provider.ListFileVe
}
func (s *service) RestoreFileVersion(ctx context.Context, req *provider.RestoreFileVersionRequest) (*provider.RestoreFileVersionResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
receivedShare, rpcStatus, err := s.resolveAcceptedShare(ctx, req.Ref)
appctx.GetLogger(ctx).Debug().
Interface("ref", req.Ref).
@@ -932,10 +880,6 @@ func (s *service) TouchFile(ctx context.Context, req *provider.TouchFileRequest)
// GetQuota returns 0 free quota. It is virtual ... the shares may have a different quota ...
func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (*provider.GetQuotaResponse, error) {
- if req.Ref.GetResourceId() != nil {
- _, req.Ref.ResourceId.StorageId = storagespace.SplitStorageID(req.Ref.ResourceId.StorageId)
- }
-
// FIXME use req.Ref to get real quota
return &provider.GetQuotaResponse{
Status: status.NewOK(ctx),
@@ -951,7 +895,7 @@ func (s *service) resolveAcceptedShare(ctx context.Context, ref *provider.Refere
return nil, status.NewInvalidArg(ctx, "sharesstorageprovider: can only handle relative references"), nil
}
- if ref.ResourceId.StorageId != utils.ShareStorageProviderID {
+ if ref.ResourceId.SpaceId != utils.ShareStorageSpaceID {
return nil, status.NewNotFound(ctx, "sharesstorageprovider: not found "+ref.String()), nil
}
@@ -1120,13 +1064,12 @@ func isRename(s, d *provider.Reference) bool {
}
func isShareJailChild(id *provider.ResourceId) bool {
- _, space := storagespace.SplitStorageID(id.StorageId)
- return space == utils.ShareStorageProviderID && id.OpaqueId != utils.ShareStorageProviderID
+ return id.SpaceId == utils.ShareStorageProviderID && id.OpaqueId != utils.ShareStorageProviderID
}
func isShareJailRoot(id *provider.ResourceId) bool {
- _, space := storagespace.SplitStorageID(id.StorageId)
- return space == utils.ShareStorageProviderID && id.OpaqueId == utils.ShareStorageProviderID
+
+ return id.SpaceId == utils.ShareStorageProviderID && id.OpaqueId == utils.ShareStorageProviderID
}
func isVirtualRoot(ref *provider.Reference) bool {
diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go
index 0cf69ea6404..e839a3c58d5 100644
--- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go
+++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider_test.go
@@ -75,7 +75,8 @@ var _ = Describe("Sharesstorageprovider", func() {
BeforeEach(func() {
ShareJail = &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
- OpaqueId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
+ OpaqueId: utils.ShareStorageSpaceID,
}
BaseShare = &collaboration.ReceivedShare{
@@ -86,6 +87,7 @@ var _ = Describe("Sharesstorageprovider", func() {
},
ResourceId: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
Permissions: &collaboration.SharePermissions{
@@ -109,6 +111,7 @@ var _ = Describe("Sharesstorageprovider", func() {
},
ResourceId: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
Permissions: &collaboration.SharePermissions{
@@ -128,7 +131,8 @@ var _ = Describe("Sharesstorageprovider", func() {
Ref: &sprovider.Reference{
ResourceId: &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
- OpaqueId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
+ OpaqueId: utils.ShareStorageSpaceID,
},
Path: ".",
},
@@ -138,6 +142,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Ref: &sprovider.Reference{
ResourceId: &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: "shareid",
},
Path: ".",
@@ -148,6 +153,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Ref: &sprovider.Reference{
ResourceId: &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: "shareid",
},
Path: ".",
@@ -171,6 +177,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-shareddir",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
PermissionSet: &sprovider.ResourcePermissions{
@@ -187,6 +194,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-subdir",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "subdir",
},
PermissionSet: &sprovider.ResourcePermissions{
@@ -203,6 +211,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-subdir-file",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "file",
},
PermissionSet: &sprovider.ResourcePermissions{
@@ -219,6 +228,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-shareddir",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
PermissionSet: &sprovider.ResourcePermissions{
@@ -251,6 +261,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-shareddir/share1-subdir",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "subdir",
},
Size: 1,
@@ -261,6 +272,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Path: "share1-shareddir/share1-subdir/share1-subdir-file",
Id: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "file",
},
Size: 1,
@@ -425,6 +437,7 @@ var _ = Describe("Sharesstorageprovider", func() {
},
ResourceId: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
Permissions: &collaboration.SharePermissions{
@@ -443,6 +456,7 @@ var _ = Describe("Sharesstorageprovider", func() {
},
ResourceId: &sprovider.ResourceId{
StorageId: "share1-storageid",
+ SpaceId: "share1-storageid",
OpaqueId: "shareddir",
},
Permissions: &collaboration.SharePermissions{
@@ -635,6 +649,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Ref: &sprovider.Reference{
ResourceId: &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: BaseShare.Share.Id.OpaqueId,
},
Path: ".",
@@ -678,6 +693,7 @@ var _ = Describe("Sharesstorageprovider", func() {
Source: &sprovider.Reference{
ResourceId: &sprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: BaseShare.Share.Id.OpaqueId,
},
Path: ".",
diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go
index ce34ddcbece..950e55f4412 100644
--- a/internal/grpc/services/storageprovider/storageprovider.go
+++ b/internal/grpc/services/storageprovider/storageprovider.go
@@ -196,9 +196,6 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
}
func (s *service) SetArbitraryMetadata(ctx context.Context, req *provider.SetArbitraryMetadataRequest) (*provider.SetArbitraryMetadataResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
err := s.storage.SetArbitraryMetadata(ctx, req.Ref, req.ArbitraryMetadata)
@@ -209,9 +206,6 @@ func (s *service) SetArbitraryMetadata(ctx context.Context, req *provider.SetArb
}
func (s *service) UnsetArbitraryMetadata(ctx context.Context, req *provider.UnsetArbitraryMetadataRequest) (*provider.UnsetArbitraryMetadataResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
err := s.storage.UnsetArbitraryMetadata(ctx, req.Ref, req.ArbitraryMetadataKeys)
@@ -223,9 +217,6 @@ func (s *service) UnsetArbitraryMetadata(ctx context.Context, req *provider.Unse
// SetLock puts a lock on the given reference
func (s *service) SetLock(ctx context.Context, req *provider.SetLockRequest) (*provider.SetLockResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
err := s.storage.SetLock(ctx, req.Ref, req.Lock)
return &provider.SetLockResponse{
@@ -235,9 +226,6 @@ func (s *service) SetLock(ctx context.Context, req *provider.SetLockRequest) (*p
// GetLock returns an existing lock on the given reference
func (s *service) GetLock(ctx context.Context, req *provider.GetLockRequest) (*provider.GetLockResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
lock, err := s.storage.GetLock(ctx, req.Ref)
return &provider.GetLockResponse{
@@ -248,9 +236,6 @@ func (s *service) GetLock(ctx context.Context, req *provider.GetLockRequest) (*p
// RefreshLock refreshes an existing lock on the given reference
func (s *service) RefreshLock(ctx context.Context, req *provider.RefreshLockRequest) (*provider.RefreshLockResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
err := s.storage.RefreshLock(ctx, req.Ref, req.Lock)
return &provider.RefreshLockResponse{
@@ -260,9 +245,6 @@ func (s *service) RefreshLock(ctx context.Context, req *provider.RefreshLockRequ
// Unlock removes an existing lock from the given reference
func (s *service) Unlock(ctx context.Context, req *provider.UnlockRequest) (*provider.UnlockResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
err := s.storage.Unlock(ctx, req.Ref, req.Lock)
return &provider.UnlockResponse{
@@ -271,9 +253,6 @@ func (s *service) Unlock(ctx context.Context, req *provider.UnlockRequest) (*pro
}
func (s *service) InitiateFileDownload(ctx context.Context, req *provider.InitiateFileDownloadRequest) (*provider.InitiateFileDownloadResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// TODO(labkode): maybe add some checks before download starts? eg. check permissions?
// TODO(labkode): maybe add short-lived token?
// We now simply point the client to the data server.
@@ -287,7 +266,7 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia
if utils.IsRelativeReference(req.Ref) {
protocol.Protocol = "spaces"
- u.Path = path.Join(u.Path, "spaces", req.Ref.ResourceId.StorageId+"!"+req.Ref.ResourceId.OpaqueId, req.Ref.Path)
+ u.Path = path.Join(u.Path, "spaces", storagespace.FormatResourceID(*req.Ref.ResourceId), req.Ref.Path)
} else {
// Currently, we only support the simple protocol for GET requests
// Once we have multiple protocols, this would be moved to the fs layer
@@ -304,9 +283,6 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia
}
func (s *service) InitiateFileUpload(ctx context.Context, req *provider.InitiateFileUploadRequest) (*provider.InitiateFileUploadResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// TODO(labkode): same considerations as download
log := appctx.GetLogger(ctx)
if req.Ref.GetPath() == "/" {
@@ -433,9 +409,6 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
}
func (s *service) GetPath(ctx context.Context, req *provider.GetPathRequest) (*provider.GetPathResponse, error) {
- providerID := unwrapProviderID(req.GetResourceId())
- defer rewrapProviderID(req.GetResourceId(), providerID)
-
// TODO(labkode): check that the storage ID is the same as the storage provider id.
fn, err := s.storage.GetPathByID(ctx, req.ResourceId)
if err != nil {
@@ -503,15 +476,6 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt
}
func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) {
- for i, f := range req.Filters {
- if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID {
- _, id := storagespace.SplitStorageID(f.GetId().GetOpaqueId())
- req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Id{Id: &provider.StorageSpaceId{OpaqueId: id}}
- } else if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_PATH {
- req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Path{Path: f.GetPath()}
- }
- }
-
log := appctx.GetLogger(ctx)
// TODO this is just temporary. Update the API to include this flag.
@@ -561,11 +525,6 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
}
func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorageSpaceRequest) (*provider.UpdateStorageSpaceResponse, error) {
- if req.GetStorageSpace().GetId() != nil {
- _, req.StorageSpace.Id.OpaqueId = storagespace.SplitStorageID(req.StorageSpace.Id.OpaqueId)
- _, req.StorageSpace.Root.StorageId = storagespace.SplitStorageID(req.StorageSpace.Root.StorageId)
- }
-
res, err := s.storage.UpdateStorageSpace(ctx, req)
if err != nil {
appctx.GetLogger(ctx).
@@ -582,10 +541,6 @@ func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateSt
}
func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorageSpaceRequest) (*provider.DeleteStorageSpaceResponse, error) {
- if req.GetId() != nil {
- _, req.Id.OpaqueId = storagespace.SplitStorageID(req.Id.OpaqueId)
- }
-
if err := s.storage.DeleteStorageSpace(ctx, req); err != nil {
var st *rpc.Status
switch err.(type) {
@@ -616,9 +571,6 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
}
func (s *service) CreateContainer(ctx context.Context, req *provider.CreateContainerRequest) (*provider.CreateContainerResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// FIXME these should be part of the CreateContainerRequest object
if req.Opaque != nil {
if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" {
@@ -634,9 +586,6 @@ func (s *service) CreateContainer(ctx context.Context, req *provider.CreateConta
}
func (s *service) TouchFile(ctx context.Context, req *provider.TouchFileRequest) (*provider.TouchFileResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// FIXME these should be part of the TouchFileRequest object
if req.Opaque != nil {
if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" {
@@ -652,9 +601,6 @@ func (s *service) TouchFile(ctx context.Context, req *provider.TouchFileRequest)
}
func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*provider.DeleteResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
if req.Ref.GetPath() == "/" {
return &provider.DeleteResponse{
Status: status.NewInternal(ctx, "can't delete mount path"),
@@ -692,11 +638,6 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
}
func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provider.MoveResponse, error) {
- sourceProviderID := unwrapProviderID(req.Source.GetResourceId())
- defer rewrapProviderID(req.Source.GetResourceId(), sourceProviderID)
- destProviderID := unwrapProviderID(req.Destination.GetResourceId())
- defer rewrapProviderID(req.Destination.GetResourceId(), destProviderID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
err := s.storage.Move(ctx, req.Source, req.Destination)
@@ -707,9 +648,6 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide
}
func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx, span := rtrace.DefaultProvider().Tracer(tracerName).Start(ctx, "stat")
defer span.End()
@@ -726,12 +664,8 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide
}
// The storage driver might set the mount ID by itself, in which case skip this step
- if mountID, _ := storagespace.SplitStorageID(md.Id.GetStorageId()); mountID == "" {
- if providerID == "" {
- providerID = s.conf.MountID
- }
-
- md.Id.StorageId = storagespace.FormatStorageID(providerID, md.Id.GetStorageId())
+ if md.Id.GetStorageId() == "" {
+ md.Id.StorageId = s.conf.MountID
}
return &provider.StatResponse{
@@ -741,9 +675,6 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide
}
func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest, ss provider.ProviderAPI_ListContainerStreamServer) error {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx := ss.Context()
log := appctx.GetLogger(ctx)
@@ -789,9 +720,6 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest,
}
func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
mds, err := s.storage.ListFolder(ctx, req.GetRef(), req.GetArbitraryMetadataKeys(), req.GetFieldMask().GetPaths())
res := &provider.ListContainerResponse{
Status: status.NewStatusFromErrType(ctx, "list container", err),
@@ -808,9 +736,6 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer
}
func (s *service) ListFileVersions(ctx context.Context, req *provider.ListFileVersionsRequest) (*provider.ListFileVersionsResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
revs, err := s.storage.ListRevisions(ctx, req.Ref)
sort.Sort(descendingMtime(revs))
@@ -822,9 +747,6 @@ func (s *service) ListFileVersions(ctx context.Context, req *provider.ListFileVe
}
func (s *service) RestoreFileVersion(ctx context.Context, req *provider.RestoreFileVersionRequest) (*provider.RestoreFileVersionResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
err := s.storage.RestoreRevision(ctx, req.Ref, req.Key)
@@ -835,9 +757,6 @@ func (s *service) RestoreFileVersion(ctx context.Context, req *provider.RestoreF
}
func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss provider.ProviderAPI_ListRecycleStreamServer) error {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx := ss.Context()
log := appctx.GetLogger(ctx)
@@ -887,9 +806,6 @@ func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss p
}
func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequest) (*provider.ListRecycleResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
key, itemPath := router.ShiftPath(req.Key)
items, err := s.storage.ListRecycle(ctx, req.Ref, key, itemPath)
if err != nil {
@@ -927,11 +843,6 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ
}
func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreRecycleItemRequest) (*provider.RestoreRecycleItemResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
- restoreProviderID := unwrapProviderID(req.RestoreRef.GetResourceId())
- defer rewrapProviderID(req.RestoreRef.GetResourceId(), restoreProviderID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
// TODO(labkode): CRITICAL: fill recycle info with storage provider.
@@ -945,9 +856,6 @@ func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreR
}
func (s *service) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleRequest) (*provider.PurgeRecycleResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// FIXME these should be part of the PurgeRecycleRequest object
if req.Opaque != nil {
if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" {
@@ -993,9 +901,6 @@ func (s *service) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleRe
}
func (s *service) ListGrants(ctx context.Context, req *provider.ListGrantsRequest) (*provider.ListGrantsResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
grants, err := s.storage.ListGrants(ctx, req.Ref)
if err != nil {
var st *rpc.Status
@@ -1026,9 +931,6 @@ func (s *service) ListGrants(ctx context.Context, req *provider.ListGrantsReques
}
func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest) (*provider.DenyGrantResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// check grantee type is valid
if req.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_INVALID {
return &provider.DenyGrantResponse{
@@ -1070,9 +972,6 @@ func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest)
}
func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (*provider.AddGrantResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
// TODO: update CS3 APIs
@@ -1099,9 +998,6 @@ func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (
}
func (s *service) UpdateGrant(ctx context.Context, req *provider.UpdateGrantRequest) (*provider.UpdateGrantResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
// FIXME these should be part of the UpdateGrantRequest object
if req.Opaque != nil {
if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" {
@@ -1124,9 +1020,6 @@ func (s *service) UpdateGrant(ctx context.Context, req *provider.UpdateGrantRequ
}
func (s *service) RemoveGrant(ctx context.Context, req *provider.RemoveGrantRequest) (*provider.RemoveGrantResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
ctx = ctxpkg.ContextSetLockID(ctx, req.LockId)
// check targetType is valid
@@ -1144,9 +1037,6 @@ func (s *service) RemoveGrant(ctx context.Context, req *provider.RemoveGrantRequ
}
func (s *service) CreateReference(ctx context.Context, req *provider.CreateReferenceRequest) (*provider.CreateReferenceResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
log := appctx.GetLogger(ctx)
// parse uri is valid
@@ -1190,9 +1080,6 @@ func (s *service) CreateSymlink(ctx context.Context, req *provider.CreateSymlink
}
func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (*provider.GetQuotaResponse, error) {
- providerID := unwrapProviderID(req.Ref.GetResourceId())
- defer rewrapProviderID(req.Ref.GetResourceId(), providerID)
-
total, used, remaining, err := s.storage.GetQuota(ctx, req.Ref)
if err != nil {
var st *rpc.Status
@@ -1233,10 +1120,12 @@ func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (
func (s *service) addMissingStorageProviderID(resourceID *provider.ResourceId, spaceID *provider.StorageSpaceId) {
// The storage driver might set the mount ID by itself, in which case skip this step
- if mountID, _ := storagespace.SplitStorageID(resourceID.GetStorageId()); mountID == "" {
- resourceID.StorageId = storagespace.FormatStorageID(s.conf.MountID, resourceID.GetStorageId())
+ if resourceID.GetStorageId() == "" {
+ resourceID.StorageId = s.conf.MountID
if spaceID != nil {
- spaceID.OpaqueId = storagespace.FormatStorageID(s.conf.MountID, spaceID.GetOpaqueId())
+ rid, _ := storagespace.ParseID(spaceID.GetOpaqueId())
+ rid.StorageId = s.conf.MountID
+ spaceID.OpaqueId, _ = storagespace.FormatReference(&provider.Reference{ResourceId: &rid})
}
}
}
@@ -1261,17 +1150,3 @@ func (v descendingMtime) Less(i, j int) bool {
func (v descendingMtime) Swap(i, j int) {
v[i], v[j] = v[j], v[i]
}
-
-func unwrapProviderID(id *provider.ResourceId) string {
- var spid string
- if id != nil {
- spid, id.StorageId = storagespace.SplitStorageID(id.StorageId)
- }
- return spid
-}
-
-func rewrapProviderID(id *provider.ResourceId, spid string) {
- if id != nil {
- id.StorageId = storagespace.FormatStorageID(spid, id.StorageId)
- }
-}
diff --git a/internal/http/services/owncloud/ocdav/ocdav.go b/internal/http/services/owncloud/ocdav/ocdav.go
index f107647ee8d..994460a3e5a 100644
--- a/internal/http/services/owncloud/ocdav/ocdav.go
+++ b/internal/http/services/owncloud/ocdav/ocdav.go
@@ -43,7 +43,6 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/favorite"
"github.com/cs3org/reva/v2/pkg/storage/favorite/registry"
"github.com/cs3org/reva/v2/pkg/storage/utils/templates"
- "github.com/cs3org/reva/v2/pkg/storagespace"
rtrace "github.com/cs3org/reva/v2/pkg/trace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
@@ -459,10 +458,7 @@ func (s *svc) sspReferenceIsChildOf(ctx context.Context, client gatewayv1beta1.G
}
func (s *svc) referenceIsChildOf(ctx context.Context, client gatewayv1beta1.GatewayAPIClient, child, parent *provider.Reference) (bool, error) {
- _, csid := storagespace.SplitStorageID(child.ResourceId.StorageId)
- _, psid := storagespace.SplitStorageID(parent.ResourceId.StorageId)
-
- if child.ResourceId.StorageId != parent.ResourceId.StorageId {
+ if child.ResourceId.SpaceId != parent.ResourceId.SpaceId {
return false, nil // Not on the same storage -> not a child
}
@@ -470,7 +466,7 @@ func (s *svc) referenceIsChildOf(ctx context.Context, client gatewayv1beta1.Gate
return strings.HasPrefix(child.Path, parent.Path+"/"), nil // Relative to the same resource -> compare paths
}
- if csid == utils.ShareStorageProviderID || psid == utils.ShareStorageProviderID {
+ if child.ResourceId.SpaceId == utils.ShareStorageSpaceID || parent.ResourceId.SpaceId == utils.ShareStorageSpaceID {
// the sharesstorageprovider needs some special handling
return s.sspReferenceIsChildOf(ctx, client, child, parent)
}
diff --git a/internal/http/services/owncloud/ocdav/ocdav_test.go b/internal/http/services/owncloud/ocdav/ocdav_test.go
index e6108d44235..67f9448d760 100644
--- a/internal/http/services/owncloud/ocdav/ocdav_test.go
+++ b/internal/http/services/owncloud/ocdav/ocdav_test.go
@@ -25,8 +25,8 @@ import (
)
func TestWrapResourceID(t *testing.T) {
- expected := "storageid" + "!" + "opaqueid"
- wrapped := storagespace.FormatResourceID(providerv1beta1.ResourceId{StorageId: "storageid", OpaqueId: "opaqueid"})
+ expected := "storageid" + "$" + "spaceid" + "!" + "opaqueid"
+ wrapped := storagespace.FormatResourceID(providerv1beta1.ResourceId{StorageId: "storageid", SpaceId: "spaceid", OpaqueId: "opaqueid"})
if wrapped != expected {
t.Errorf("wrapped id doesn't have the expected format: got %s expected %s", wrapped, expected)
diff --git a/internal/http/services/owncloud/ocdav/propfind/propfind.go b/internal/http/services/owncloud/ocdav/propfind/propfind.go
index df90d295d48..d10bcd0ae51 100644
--- a/internal/http/services/owncloud/ocdav/propfind/propfind.go
+++ b/internal/http/services/owncloud/ocdav/propfind/propfind.go
@@ -960,7 +960,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
}
// replace fileid of /public/{token} mountpoint with grant fileid
- if ls != nil && md.Id != nil && md.Id.StorageId == utils.PublicStorageProviderID && md.Id.OpaqueId == ls.Token {
+ if ls != nil && md.Id != nil && md.Id.SpaceId == utils.PublicStorageSpaceID && md.Id.OpaqueId == ls.Token {
md.Id = ls.ResourceId
}
@@ -981,7 +981,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
propstatOK.Prop = append(propstatOK.Prop,
prop.Escaped("oc:id", id),
prop.Escaped("oc:fileid", id),
- prop.Escaped("oc:spaceid", md.Id.StorageId),
+ prop.Escaped("oc:spaceid", md.Id.SpaceId),
)
}
@@ -1093,7 +1093,7 @@ func mdToPropResponse(ctx context.Context, pf *XML, md *provider.ResourceInfo, p
}
case "spaceid":
if md.Id != nil {
- propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:spaceid", md.Id.StorageId))
+ propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:spaceid", md.Id.SpaceId))
} else {
propstatNotFound.Prop = append(propstatNotFound.Prop, prop.Escaped("oc:spaceid", ""))
}
diff --git a/internal/http/services/owncloud/ocdav/propfind/propfind_test.go b/internal/http/services/owncloud/ocdav/propfind/propfind_test.go
index 0816ed7ef64..c7e80d11819 100644
--- a/internal/http/services/owncloud/ocdav/propfind/propfind_test.go
+++ b/internal/http/services/owncloud/ocdav/propfind/propfind_test.go
@@ -34,6 +34,7 @@ import (
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
+ "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/tests/cs3mocks/mocks"
"github.com/stretchr/testify/mock"
@@ -106,8 +107,8 @@ var _ = Describe("Propfind", func() {
},
},
},
- Id: &sprovider.StorageSpaceId{OpaqueId: "foospace!root"},
- Root: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"},
+ Id: &sprovider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"})},
+ Root: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"},
Name: "foospace",
}
fooquxspace = &sprovider.StorageSpace{
@@ -119,8 +120,8 @@ var _ = Describe("Propfind", func() {
},
},
},
- Id: &sprovider.StorageSpaceId{OpaqueId: "fooquxspace!root"},
- Root: &sprovider.ResourceId{StorageId: "fooquxspace", OpaqueId: "root"},
+ Id: &sprovider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "root"})},
+ Root: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "root"},
Name: "fooquxspace",
}
fooFileShareSpace = &sprovider.StorageSpace{
@@ -132,8 +133,8 @@ var _ = Describe("Propfind", func() {
},
},
},
- Id: &sprovider.StorageSpaceId{OpaqueId: "fooFileShareSpace!sharedfile"},
- Root: &sprovider.ResourceId{StorageId: "fooFileShareSpace", OpaqueId: "sharedfile"},
+ Id: &sprovider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace", OpaqueId: "sharedfile"})},
+ Root: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace", OpaqueId: "sharedfile"},
Name: "fooFileShareSpace",
}
fooFileShare2Space = &sprovider.StorageSpace{
@@ -145,8 +146,8 @@ var _ = Describe("Propfind", func() {
},
},
},
- Id: &sprovider.StorageSpaceId{OpaqueId: "fooFileShareSpace2!sharedfile2"},
- Root: &sprovider.ResourceId{StorageId: "fooFileShareSpace2", OpaqueId: "sharedfile2"},
+ Id: &sprovider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace2", OpaqueId: "sharedfile2"})},
+ Root: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace2", OpaqueId: "sharedfile2"},
Name: "fooFileShareSpace2",
}
fooDirShareSpace = &sprovider.StorageSpace{
@@ -158,8 +159,8 @@ var _ = Describe("Propfind", func() {
},
},
},
- Id: &sprovider.StorageSpaceId{OpaqueId: "fooDirShareSpace!shareddir"},
- Root: &sprovider.ResourceId{StorageId: "fooDirShareSpace", OpaqueId: "shareddir"},
+ Id: &sprovider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddir"})},
+ Root: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddir"},
Name: "fooDirShareSpace",
}
@@ -169,89 +170,89 @@ var _ = Describe("Propfind", func() {
// - ./baz, file, 1 byte, opaqueid "baz"
// - ./dir, folder, 30 bytes, opaqueid "dir"
// - ./dir/entry, file, 30 bytes, opaqueid "direntry"
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: ".",
Size: uint64(131),
})
- mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "."},
+ mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "."},
[]*sprovider.ResourceInfo{
{
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "bar"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "bar"},
Path: "bar",
Size: 100,
},
{
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "baz"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "baz"},
Path: "baz",
Size: 1,
},
{
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "dir"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "dir"},
Path: "dir",
Size: 30,
},
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "./bar"},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "./bar"},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "bar"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "bar"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "./bar",
Size: uint64(100),
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "bar"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "bar"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "bar"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "bar"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "./bar",
Size: uint64(100),
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "./baz"},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "./baz"},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "baz"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "baz"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "./baz",
Size: uint64(1),
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "baz"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "baz"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "baz"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "baz"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "./baz",
Size: uint64(1),
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "./dir"},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "./dir"},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "dir"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "dir"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: "./dir",
Size: uint64(30),
})
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "dir"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "dir"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "dir"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "dir"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: "./dir",
Size: uint64(30),
})
- mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "root"}, Path: "./dir"},
+ mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"}, Path: "./dir"},
[]*sprovider.ResourceInfo{
{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "direntry"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "direntry"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "entry",
Size: 30,
},
})
- mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "dir"}, Path: "."},
+ mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "dir"}, Path: "."},
[]*sprovider.ResourceInfo{
{
- Id: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "direntry"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "direntry"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "entry",
Size: 30,
@@ -261,28 +262,28 @@ var _ = Describe("Propfind", func() {
// For the space mounted a /foo/qux we assign a storageid "foospace" and a root opaqueid "root"
// it contains one resource
// - ./quux, file, 1000 bytes, opaqueid "quux"
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooquxspace", OpaqueId: "root"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "root"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "fooquxspace", OpaqueId: "root"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "root"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: ".",
Size: uint64(1000),
})
- mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooquxspace", OpaqueId: "root"}, Path: "."},
+ mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "root"}, Path: "."},
[]*sprovider.ResourceInfo{
{
- Id: &sprovider.ResourceId{StorageId: "fooquxspace", OpaqueId: "quux"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooquxspace", OpaqueId: "quux"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "./quux",
Size: 1000,
},
})
- // For the space mounted a /foo/Shares/sharedFile we assign a storageid "fooFileShareSpace" and a root opaqueid "sharedfile"
+ // For the space mounted a /foo/Shares/sharedFile we assign a spaceid "fooFileShareSpace" and a root opaqueid "sharedfile"
// it is a file resource, 2000 bytes, opaqueid "sharedfile"
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooFileShareSpace", OpaqueId: "sharedfile"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace", OpaqueId: "sharedfile"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "fooFileShareSpace", OpaqueId: "sharedfile"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace", OpaqueId: "sharedfile"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: ".",
Size: uint64(2000),
@@ -290,11 +291,11 @@ var _ = Describe("Propfind", func() {
Etag: "1",
})
- // For the space mounted a /foo/Shares/sharedFile2 we assign a storageid "fooFileShareSpace2" and a root opaqueid "sharedfile2"
+ // For the space mounted a /foo/Shares/sharedFile2 we assign a spaceid "fooFileShareSpace2" and a root opaqueid "sharedfile2"
// it is a file resource, 2500 bytes, opaqueid "sharedfile2"
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooFileShareSpace2", OpaqueId: "sharedfile2"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace2", OpaqueId: "sharedfile2"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "fooFileShareSpace2", OpaqueId: "sharedfile2"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooFileShareSpace2", OpaqueId: "sharedfile2"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: ".",
Size: uint64(2500),
@@ -302,22 +303,22 @@ var _ = Describe("Propfind", func() {
Etag: "2",
})
- // For the space mounted a /foo/Shares/sharedFile2 we assign a storageid "fooDirShareSpace" and a root opaqueid "shareddir"
+ // For the space mounted a /foo/Shares/sharedFile2 we assign a spaceid "fooDirShareSpace" and a root opaqueid "shareddir"
// it is a folder containing one resource
// ./something, file, 1500 bytes, opaqueid "shareddirsomething"
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooDirShareSpace", OpaqueId: "shareddir"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddir"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{StorageId: "fooDirShareSpace", OpaqueId: "shareddir"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddir"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: ".",
Size: uint64(1500),
Mtime: &typesv1beta1.Timestamp{Seconds: 3},
Etag: "3",
})
- mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "fooDirShareSpace", OpaqueId: "shareddir"}, Path: "."},
+ mockListContainer(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddir"}, Path: "."},
[]*sprovider.ResourceInfo{
{
- Id: &sprovider.ResourceId{StorageId: "fooDirShareSpace", OpaqueId: "shareddirsomething"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "fooDirShareSpace", OpaqueId: "shareddirsomething"},
Type: sprovider.ResourceType_RESOURCE_TYPE_FILE,
Path: "something",
Size: 1500,
@@ -337,7 +338,7 @@ var _ = Describe("Propfind", func() {
shares = []*link.PublicShare{
{
Id: &link.PublicShareId{OpaqueId: "share1"},
- ResourceId: &sprovider.ResourceId{StorageId: "foospace", OpaqueId: "bar"},
+ ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "bar"},
},
}
default:
@@ -371,9 +372,9 @@ var _ = Describe("Propfind", func() {
Status: status.NewOK(ctx),
StorageSpaces: []*sprovider.StorageSpace{},
}, nil)
- mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{OpaqueId: "foospace", StorageId: "foospace"}, Path: "."},
+ mockStat(&sprovider.Reference{ResourceId: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "foospace"}, Path: "."},
&sprovider.ResourceInfo{
- Id: &sprovider.ResourceId{OpaqueId: "foospace", StorageId: "foospace"},
+ Id: &sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "foospace"},
Type: sprovider.ResourceType_RESOURCE_TYPE_CONTAINER,
Path: ".",
Size: uint64(131),
@@ -733,7 +734,9 @@ var _ = Describe("Propfind", func() {
Expect(err).ToNot(HaveOccurred())
req = req.WithContext(ctx)
- handler.HandleSpacesPropfind(rr, req, "foospace!root")
+ spaceID := storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"})
+ spaceIDUrl := net.EncodePath(spaceID)
+ handler.HandleSpacesPropfind(rr, req, spaceID)
Expect(rr.Code).To(Equal(http.StatusMultiStatus))
res, _, err := readResponse(rr.Result().Body)
@@ -741,19 +744,19 @@ var _ = Describe("Propfind", func() {
Expect(len(res.Responses)).To(Equal(4))
root := res.Responses[0]
- Expect(root.Href).To(Equal("http:/127.0.0.1:3000/foospace%21root/"))
+ Expect(root.Href).To(Equal("http:/127.0.0.1:3000/" + spaceIDUrl + "/"))
Expect(string(root.Propstat[0].Prop[0].InnerXML)).To(ContainSubstring("131"))
bar := res.Responses[1]
- Expect(bar.Href).To(Equal("http:/127.0.0.1:3000/foospace%21root/bar"))
+ Expect(bar.Href).To(Equal("http:/127.0.0.1:3000/" + spaceIDUrl + "/bar"))
Expect(string(bar.Propstat[0].Prop[0].InnerXML)).To(ContainSubstring("100"))
baz := res.Responses[2]
- Expect(baz.Href).To(Equal("http:/127.0.0.1:3000/foospace%21root/baz"))
+ Expect(baz.Href).To(Equal("http:/127.0.0.1:3000/" + spaceIDUrl + "/baz"))
Expect(string(baz.Propstat[0].Prop[0].InnerXML)).To(ContainSubstring("1"))
dir := res.Responses[3]
- Expect(dir.Href).To(Equal("http:/127.0.0.1:3000/foospace%21root/dir/"))
+ Expect(dir.Href).To(Equal("http:/127.0.0.1:3000/" + spaceIDUrl + "/dir/"))
Expect(string(dir.Propstat[0].Prop[0].InnerXML)).To(ContainSubstring("30"))
})
@@ -763,7 +766,8 @@ var _ = Describe("Propfind", func() {
Expect(err).ToNot(HaveOccurred())
req = req.WithContext(ctx)
- handler.HandleSpacesPropfind(rr, req, "foospace!root")
+ spaceID := storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"})
+ handler.HandleSpacesPropfind(rr, req, spaceID)
Expect(rr.Code).To(Equal(http.StatusMultiStatus))
res, _, err := readResponse(rr.Result().Body)
@@ -778,7 +782,8 @@ var _ = Describe("Propfind", func() {
Expect(err).ToNot(HaveOccurred())
req = req.WithContext(ctx)
- handler.HandleSpacesPropfind(rr, req, "foospace!root")
+ spaceID := storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"})
+ handler.HandleSpacesPropfind(rr, req, spaceID)
Expect(rr.Code).To(Equal(http.StatusMultiStatus))
res, _, err := readResponse(rr.Result().Body)
@@ -795,7 +800,9 @@ var _ = Describe("Propfind", func() {
Expect(err).ToNot(HaveOccurred())
req = req.WithContext(ctx)
- handler.HandleSpacesPropfind(rr, req, "foospace!root")
+ spaceID := storagespace.FormatResourceID(sprovider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "root"})
+ spaceIDUrl := net.EncodePath(spaceID)
+ handler.HandleSpacesPropfind(rr, req, spaceID)
Expect(rr.Code).To(Equal(http.StatusMultiStatus))
res, _, err := readResponse(rr.Result().Body)
@@ -807,11 +814,11 @@ var _ = Describe("Propfind", func() {
paths = append(paths, r.Href)
}
Expect(paths).To(ConsistOf(
- "http:/127.0.0.1:3000/foospace%21root/",
- "http:/127.0.0.1:3000/foospace%21root/bar",
- "http:/127.0.0.1:3000/foospace%21root/baz",
- "http:/127.0.0.1:3000/foospace%21root/dir/",
- "http:/127.0.0.1:3000/foospace%21root/dir/entry",
+ "http:/127.0.0.1:3000/"+spaceIDUrl+"/",
+ "http:/127.0.0.1:3000/"+spaceIDUrl+"/bar",
+ "http:/127.0.0.1:3000/"+spaceIDUrl+"/baz",
+ "http:/127.0.0.1:3000/"+spaceIDUrl+"/dir/",
+ "http:/127.0.0.1:3000/"+spaceIDUrl+"/dir/entry",
))
})
})
diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go
index e7dc3ee49e7..415dad12558 100644
--- a/internal/http/services/owncloud/ocdav/trashbin.go
+++ b/internal/http/services/owncloud/ocdav/trashbin.go
@@ -191,7 +191,7 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
if depth == net.DepthZero {
rootHref := path.Join(refBase, key, itemPath)
- propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, rootHref, nil, nil)
+ propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.SpaceId, refBase, rootHref, nil, nil)
if err != nil {
sublog.Error().Err(err).Msg("error formatting propfind")
w.WriteHeader(http.StatusInternalServerError)
@@ -276,7 +276,7 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
}
rootHref := path.Join(refBase, key, itemPath)
- propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, rootHref, &pf, items)
+ propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.SpaceId, refBase, rootHref, &pf, items)
if err != nil {
sublog.Error().Err(err).Msg("error formatting propfind")
w.WriteHeader(http.StatusInternalServerError)
diff --git a/internal/http/services/owncloud/ocdav/versions.go b/internal/http/services/owncloud/ocdav/versions.go
index 24e4696ff9e..155c3f92eef 100644
--- a/internal/http/services/owncloud/ocdav/versions.go
+++ b/internal/http/services/owncloud/ocdav/versions.go
@@ -83,6 +83,7 @@ func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler
ref := &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: rid.StorageId,
+ SpaceId: rid.SpaceId,
OpaqueId: key,
},
Path: utils.MakeRelativePath(r.URL.Path),
@@ -94,6 +95,7 @@ func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler
ref := &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: rid.StorageId,
+ SpaceId: rid.SpaceId,
OpaqueId: key,
},
Path: utils.MakeRelativePath(r.URL.Path),
diff --git a/internal/http/services/owncloud/ocs/conversions/main.go b/internal/http/services/owncloud/ocs/conversions/main.go
index ef087fdf53a..97d7660312d 100644
--- a/internal/http/services/owncloud/ocs/conversions/main.go
+++ b/internal/http/services/owncloud/ocs/conversions/main.go
@@ -178,6 +178,7 @@ type TokenInfo struct {
// if not password protected
StorageID string `json:"storage_id" xml:"storage_id"`
+ SpaceID string `json:"space_id" xml:"space_id"`
OpaqueID string `json:"opaque_id" xml:"opaque_id"`
Path string `json:"path" xml:"path"`
diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees/token.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees/token.go
index 76b2c670c46..29d36303a4c 100644
--- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees/token.go
+++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees/token.go
@@ -37,6 +37,7 @@ import (
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
+ "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"google.golang.org/grpc/metadata"
)
@@ -81,7 +82,7 @@ func handleGetToken(ctx context.Context, tkn string, pw string, c gateway.Gatewa
}
if protected && !t.PasswordProtected {
- space, status, err := spacelookup.LookUpStorageSpaceByID(ctx, c, t.StorageID)
+ space, status, err := spacelookup.LookUpStorageSpaceByID(ctx, c, storagespace.FormatResourceID(provider.ResourceId{StorageId: t.StorageID, SpaceId: t.SpaceID, OpaqueId: t.OpaqueID}))
// add info only if user is able to stat
if err == nil && status.Code == rpc.Code_CODE_OK {
t.SpacePath = utils.ReadPlainFromOpaque(space.Opaque, "path")
@@ -114,6 +115,7 @@ func buildTokenInfo(owner *user.User, tkn string, token string, passProtected bo
_ = json.Unmarshal(sRes.Info.Opaque.Map["link-share"].Value, ls)
t.StorageID = ls.ResourceId.GetStorageId()
+ t.SpaceID = ls.ResourceId.GetSpaceId()
t.OpaqueID = ls.ResourceId.GetOpaqueId()
return t, nil
diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go
index 71e767d3ab7..bea2cb13b05 100644
--- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go
+++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go
@@ -863,7 +863,8 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) {
// first stat mount point, but the shares storage provider only handles accepted shares so we send the try to make the requests for only those
if rs.State == collaboration.ShareState_SHARE_STATE_ACCEPTED {
mountID := &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID),
+ StorageId: utils.ShareStorageProviderID,
+ SpaceId: utils.ShareStorageSpaceID,
OpaqueId: rs.Share.Id.OpaqueId,
}
info, status, err = h.getResourceInfoByID(ctx, client, mountID)
diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/spaces.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/spaces.go
index 4274a3d08ce..bf7ce4e2a87 100644
--- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/spaces.go
+++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/spaces.go
@@ -211,6 +211,7 @@ func (h *Handler) findProvider(ctx context.Context, ref *provider.Reference) (*r
}
if ref.ResourceId != nil {
filters["storage_id"] = ref.ResourceId.StorageId
+ filters["space_id"] = ref.ResourceId.SpaceId
filters["opaque_id"] = ref.ResourceId.OpaqueId
}
diff --git a/pkg/app/provider/demo/demo.go b/pkg/app/provider/demo/demo.go
index 5a1672f9f32..a2552364d2c 100644
--- a/pkg/app/provider/demo/demo.go
+++ b/pkg/app/provider/demo/demo.go
@@ -27,6 +27,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/app"
"github.com/cs3org/reva/v2/pkg/app/provider/registry"
+ "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/mitchellh/mapstructure"
)
@@ -39,7 +40,7 @@ type demoProvider struct {
}
func (p *demoProvider) GetAppURL(ctx context.Context, resource *provider.ResourceInfo, viewMode appprovider.OpenInAppRequest_ViewMode, token string) (*appprovider.OpenInAppURL, error) {
- url := fmt.Sprintf("", p.iframeUIProvider, resource.Id.StorageId+":"+resource.Id.OpaqueId, viewMode.String(), token)
+ url := fmt.Sprintf("", p.iframeUIProvider, storagespace.FormatResourceID(*resource.Id), viewMode.String(), token)
return &appprovider.OpenInAppURL{
AppUrl: url,
Method: "GET",
diff --git a/pkg/app/provider/wopi/wopi.go b/pkg/app/provider/wopi/wopi.go
index a66e3174af2..d24561c68e4 100644
--- a/pkg/app/provider/wopi/wopi.go
+++ b/pkg/app/provider/wopi/wopi.go
@@ -135,7 +135,7 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
q := httpReq.URL.Query()
q.Add("fileid", resource.GetId().OpaqueId)
- q.Add("endpoint", resource.GetId().StorageId)
+ q.Add("endpoint", resource.GetId().SpaceId)
q.Add("viewmode", viewMode.String())
u, ok := ctxpkg.ContextGetUser(ctx)
diff --git a/pkg/auth/scope/resourceinfo.go b/pkg/auth/scope/resourceinfo.go
index f89ac832ba4..769f3aa5dd8 100644
--- a/pkg/auth/scope/resourceinfo.go
+++ b/pkg/auth/scope/resourceinfo.go
@@ -109,7 +109,7 @@ func resourceinfoScope(_ context.Context, scope *authpb.Scope, resource interfac
func checkResourceInfo(inf *provider.ResourceInfo, ref *provider.Reference) bool {
// ref: >
if ref.ResourceId != nil { // path can be empty or a relative path
- if inf.Id.StorageId == ref.ResourceId.StorageId && inf.Id.OpaqueId == ref.ResourceId.OpaqueId {
+ if inf.Id.SpaceId == ref.ResourceId.SpaceId && inf.Id.OpaqueId == ref.ResourceId.OpaqueId {
if ref.Path == "" {
// id only reference
return true
diff --git a/pkg/cbox/favorite/sql/sql.go b/pkg/cbox/favorite/sql/sql.go
index e2b152814be..180a3448155 100644
--- a/pkg/cbox/favorite/sql/sql.go
+++ b/pkg/cbox/favorite/sql/sql.go
@@ -29,7 +29,6 @@ import (
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storage/favorite"
"github.com/cs3org/reva/v2/pkg/storage/favorite/registry"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/mitchellh/mapstructure"
)
@@ -80,10 +79,9 @@ func (m *mgr) ListFavorites(ctx context.Context, userID *user.UserId) ([]*provid
for rows.Next() {
var info provider.ResourceId
- if err := rows.Scan(&info.StorageId, &info.OpaqueId); err != nil {
+ if err := rows.Scan(&info.SpaceId, &info.OpaqueId); err != nil {
return nil, err
}
- info.StorageId = storagespace.FormatStorageID(info.StorageId, info.OpaqueId)
infos = append(infos, &info)
}
@@ -95,19 +93,19 @@ func (m *mgr) ListFavorites(ctx context.Context, userID *user.UserId) ([]*provid
func (m *mgr) SetFavorite(ctx context.Context, userID *user.UserId, resourceInfo *provider.ResourceInfo) error {
user := ctxpkg.ContextMustGetUser(ctx)
- storageID, _ := storagespace.SplitStorageID(resourceInfo.Id.StorageId)
+ spaceID := resourceInfo.Id.SpaceId
// The primary key is just the ID in the table, it should ideally be (uid, fileid_prefix, fileid, tag_key)
// For the time being, just check if the favorite already exists. If it does, return early
var id int
query := `SELECT id FROM cbox_metadata WHERE uid=? AND fileid_prefix=? AND fileid=? AND tag_key="fav"`
- if err := m.db.QueryRow(query, user.Id.OpaqueId, storageID, resourceInfo.Id.OpaqueId).Scan(&id); err == nil {
+ if err := m.db.QueryRow(query, user.Id.OpaqueId, spaceID, resourceInfo.Id.OpaqueId).Scan(&id); err == nil {
// Favorite is already set, return
return nil
}
query = `INSERT INTO cbox_metadata SET item_type=?, uid=?, fileid_prefix=?, fileid=?, tag_key="fav"`
- vals := []interface{}{utils.ResourceTypeToItemInt(resourceInfo.Type), user.Id.OpaqueId, storageID, resourceInfo.Id.OpaqueId}
+ vals := []interface{}{utils.ResourceTypeToItemInt(resourceInfo.Type), user.Id.OpaqueId, spaceID, resourceInfo.Id.OpaqueId}
stmt, err := m.db.Prepare(query)
if err != nil {
return err
@@ -121,14 +119,14 @@ func (m *mgr) SetFavorite(ctx context.Context, userID *user.UserId, resourceInfo
func (m *mgr) UnsetFavorite(ctx context.Context, userID *user.UserId, resourceInfo *provider.ResourceInfo) error {
user := ctxpkg.ContextMustGetUser(ctx)
- storageID, _ := storagespace.SplitStorageID(resourceInfo.Id.StorageId)
+ spaceID := resourceInfo.Id.SpaceId
stmt, err := m.db.Prepare(`DELETE FROM cbox_metadata WHERE uid=? AND fileid_prefix=? AND fileid=? AND tag_key="fav"`)
if err != nil {
return err
}
- res, err := stmt.Exec(user.Id.OpaqueId, storageID, resourceInfo.Id.OpaqueId)
+ res, err := stmt.Exec(user.Id.OpaqueId, spaceID, resourceInfo.Id.OpaqueId)
if err != nil {
return err
}
diff --git a/pkg/cbox/publicshare/sql/sql.go b/pkg/cbox/publicshare/sql/sql.go
index 6dda3803bf3..7249584adef 100644
--- a/pkg/cbox/publicshare/sql/sql.go
+++ b/pkg/cbox/publicshare/sql/sql.go
@@ -39,7 +39,6 @@ import (
"github.com/cs3org/reva/v2/pkg/errtypes"
"github.com/cs3org/reva/v2/pkg/publicshare"
"github.com/cs3org/reva/v2/pkg/publicshare/manager/registry"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
@@ -134,7 +133,8 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
owner := conversions.FormatUserID(rInfo.Owner)
permissions := conversions.SharePermToInt(g.Permissions.Permissions)
itemType := conversions.ResourceTypeToItem(rInfo.Type)
- prefix, _ := storagespace.SplitStorageID(rInfo.Id.StorageId)
+ // TODO, we need to store also a spaceID
+ prefix := rInfo.Id.StorageId
itemSource := rInfo.Id.OpaqueId
fileSource, err := strconv.ParseUint(itemSource, 10, 64)
if err != nil {
@@ -323,8 +323,7 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
resourceFilters += " OR "
}
resourceFilters += "(fileid_prefix=? AND item_source=?)"
- prefix, _ := storagespace.SplitStorageID(f.GetResourceId().StorageId)
- resourceParams = append(resourceParams, prefix, f.GetResourceId().OpaqueId)
+ resourceParams = append(resourceParams, f.GetResourceId().StorageId, f.GetResourceId().OpaqueId)
case link.ListPublicSharesRequest_Filter_TYPE_OWNER:
if len(ownerFilters) != 0 {
ownerFilters += " OR "
diff --git a/pkg/cbox/share/sql/sql.go b/pkg/cbox/share/sql/sql.go
index e5956096d45..d37d108bc34 100644
--- a/pkg/cbox/share/sql/sql.go
+++ b/pkg/cbox/share/sql/sql.go
@@ -35,7 +35,6 @@ import (
"github.com/cs3org/reva/v2/pkg/errtypes"
"github.com/cs3org/reva/v2/pkg/share"
"github.com/cs3org/reva/v2/pkg/share/manager/registry"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
@@ -126,7 +125,7 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceInfo, g *collabora
itemType := conversions.ResourceTypeToItem(md.Type)
targetPath := path.Join("/", path.Base(md.Path))
permissions := conversions.SharePermToInt(g.Permissions.Permissions)
- prefix, _ := storagespace.SplitStorageID(md.Id.StorageId)
+ prefix := md.Id.StorageId
itemSource := md.Id.OpaqueId
fileSource, err := strconv.ParseUint(itemSource, 10, 64)
if err != nil {
@@ -525,8 +524,7 @@ func translateFilters(filters []*collaboration.Filter) (string, []interface{}, e
filterQuery += "("
for i, f := range filters {
filterQuery += "(fileid_prefix =? AND item_source=?)"
- prefix, _ := storagespace.SplitStorageID(f.GetResourceId().StorageId)
- params = append(params, prefix, f.GetResourceId().OpaqueId)
+ params = append(params, f.GetResourceId().StorageId, f.GetResourceId().OpaqueId)
if i != len(filters)-1 {
filterQuery += " OR "
diff --git a/pkg/cbox/storage/eoswrapper/eoswrapper.go b/pkg/cbox/storage/eoswrapper/eoswrapper.go
index 3c7cad877f7..6f1e0837461 100644
--- a/pkg/cbox/storage/eoswrapper/eoswrapper.go
+++ b/pkg/cbox/storage/eoswrapper/eoswrapper.go
@@ -118,7 +118,6 @@ func (w *wrapper) GetMD(ctx context.Context, ref *provider.Reference, mdKeys []s
// Take the first letter of the resource path after the namespace has been removed.
// If it's empty, leave it empty to be filled by storageprovider.
res.Id.StorageId = w.getMountID(ctx, res)
- res.Id.StorageId = storagespace.FormatStorageID(res.Id.StorageId, res.Id.OpaqueId)
if err = w.setProjectSharingPermissions(ctx, res); err != nil {
return nil, err
@@ -139,7 +138,6 @@ func (w *wrapper) ListFolder(ctx context.Context, ref *provider.Reference, mdKey
}
for _, r := range res {
r.Id.StorageId = w.getMountID(ctx, r)
- r.Id.StorageId = storagespace.FormatStorageID(r.Id.StorageId, r.Id.OpaqueId)
// If the request contains a relative reference, we also need to return the base path instead of the full one
if utils.IsRelativeReference(ref) {
@@ -177,11 +175,9 @@ func (w *wrapper) ListStorageSpaces(ctx context.Context, filter []*provider.List
}
for _, r := range res {
- if mountID, _ := storagespace.SplitStorageID(r.Id.OpaqueId); mountID == "" {
+ if mountID, _, _, _ := storagespace.SplitID(r.Id.OpaqueId); mountID == "" {
mountID = w.getMountID(ctx, &provider.ResourceInfo{Path: r.Name})
-
- r.Root.StorageId = storagespace.FormatStorageID(mountID, r.Root.StorageId)
- r.Id.OpaqueId = storagespace.FormatStorageID(mountID, r.Id.OpaqueId)
+ r.Root.StorageId = mountID
}
}
return res, nil
diff --git a/pkg/cbox/utils/conversions.go b/pkg/cbox/utils/conversions.go
index 1bf43e03409..d63b5d7446a 100644
--- a/pkg/cbox/utils/conversions.go
+++ b/pkg/cbox/utils/conversions.go
@@ -29,7 +29,6 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/conversions"
- "github.com/cs3org/reva/v2/pkg/storagespace"
)
// DBShare stores information about user and public shares.
@@ -196,8 +195,9 @@ func ConvertToCS3Share(s DBShare) *collaboration.Share {
},
//ResourceId: &provider.Reference{StorageId: s.Prefix, NodeId: s.ItemSource},
ResourceId: &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(s.Prefix, s.ItemSource),
- OpaqueId: s.ItemSource,
+ StorageId: s.Prefix,
+ // SpaceId: TODO: we need to add the spaceID
+ OpaqueId: s.ItemSource,
},
Permissions: &collaboration.SharePermissions{Permissions: IntTosharePerm(s.Permissions, s.ItemType)},
Grantee: ExtractGrantee(s.ShareType, s.ShareWith),
@@ -240,8 +240,9 @@ func ConvertToCS3PublicShare(s DBShare) *link.PublicShare {
OpaqueId: s.ID,
},
ResourceId: &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(s.Prefix, s.ItemSource),
- OpaqueId: s.ItemSource,
+ StorageId: s.Prefix,
+ // SpaceId: TODO: we also need a spaceID
+ OpaqueId: s.ItemSource,
},
Permissions: &link.PublicSharePermissions{Permissions: IntTosharePerm(s.Permissions, s.ItemType)},
Owner: ExtractUserID(s.UIDOwner),
diff --git a/pkg/rhttp/datatx/manager/spaces/spaces.go b/pkg/rhttp/datatx/manager/spaces/spaces.go
index d3c6117cf89..a6dfc5db09f 100644
--- a/pkg/rhttp/datatx/manager/spaces/spaces.go
+++ b/pkg/rhttp/datatx/manager/spaces/spaces.go
@@ -87,12 +87,15 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {
fn := path.Clean(strings.TrimLeft(r.URL.Path, "/"))
defer r.Body.Close()
- storageid, opaqeid, _ := storagespace.SplitID(spaceID)
+ rid, err := storagespace.ParseID(spaceID)
+ if err != nil {
+ sublog.Error().Err(err).Msg("failed to parse resourceID")
+ }
ref := &provider.Reference{
- ResourceId: &provider.ResourceId{StorageId: storageid, OpaqueId: opaqeid},
+ ResourceId: &rid,
Path: fn,
}
- err := fs.Upload(ctx, ref, r.Body, func(owner *userpb.UserId, ref *provider.Reference) {
+ err = fs.Upload(ctx, ref, r.Body, func(owner *userpb.UserId, ref *provider.Reference) {
if err := datatx.EmitFileUploadedEvent(owner, ref, m.publisher); err != nil {
sublog.Error().Err(err).Msg("failed to publish FileUploaded event")
}
diff --git a/pkg/rhttp/datatx/manager/tus/tus.go b/pkg/rhttp/datatx/manager/tus/tus.go
index 0a550993943..684888a6fd0 100644
--- a/pkg/rhttp/datatx/manager/tus/tus.go
+++ b/pkg/rhttp/datatx/manager/tus/tus.go
@@ -35,7 +35,6 @@ import (
"github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/registry"
"github.com/cs3org/reva/v2/pkg/rhttp/datatx/utils/download"
"github.com/cs3org/reva/v2/pkg/storage"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
)
@@ -110,7 +109,8 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {
}
ref := &provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(info.MetaData["providerID"], info.Storage["SpaceRoot"]),
+ StorageId: info.MetaData["providerID"],
+ SpaceId: info.Storage["SpaceRoot"],
OpaqueId: info.Storage["SpaceRoot"],
},
Path: utils.MakeRelativePath(filepath.Join(info.MetaData["dir"], info.MetaData["filename"])),
diff --git a/pkg/rhttp/datatx/utils/download/download.go b/pkg/rhttp/datatx/utils/download/download.go
index 77f6960cc5b..7374edb2af5 100644
--- a/pkg/rhttp/datatx/utils/download/download.go
+++ b/pkg/rhttp/datatx/utils/download/download.go
@@ -55,9 +55,12 @@ func GetOrHeadFile(w http.ResponseWriter, r *http.Request, fs storage.FS, spaceI
ref = &provider.Reference{Path: path.Join("/", fn)}
} else {
// build a storage space reference
- storageid, opaqeid, _ := storagespace.SplitID(spaceID)
+ rid, err := storagespace.ParseID(spaceID)
+ if err != nil {
+ handleError(w, &sublog, err, "parse ID")
+ }
ref = &provider.Reference{
- ResourceId: &provider.ResourceId{StorageId: storageid, OpaqueId: opaqeid},
+ ResourceId: &rid,
// ensure the relative path starts with '.'
Path: utils.MakeRelativePath(fn),
}
diff --git a/pkg/share/share.go b/pkg/share/share.go
index 32854844140..3bacf8406ec 100644
--- a/pkg/share/share.go
+++ b/pkg/share/share.go
@@ -163,7 +163,7 @@ func MatchesFilter(share *collaboration.Share, filter *collaboration.Filter) boo
// I.e. if the permission is 0 we don't want to show it.
return int(conversions.RoleFromResourcePermissions(share.Permissions.Permissions).OCSPermissions()) != 0
case StorageIDFilterType:
- return share.ResourceId.StorageId == filter.GetResourceId().GetStorageId()
+ return share.ResourceId.SpaceId == filter.GetResourceId().GetSpaceId()
default:
return false
}
diff --git a/pkg/storage/fs/owncloudsql/spaces.go b/pkg/storage/fs/owncloudsql/spaces.go
index 9b07348b9c8..04f1a2d1557 100644
--- a/pkg/storage/fs/owncloudsql/spaces.go
+++ b/pkg/storage/fs/owncloudsql/spaces.go
@@ -47,7 +47,7 @@ func (fs *owncloudsqlfs) ListStorageSpaces(ctx context.Context, filter []*provid
t := filter[i].GetSpaceType()
filteringUnsupportedSpaceTypes = (t != "personal" && !strings.HasPrefix(t, "+"))
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- spaceID, _, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
+ _, spaceID, _, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
}
}
if filteringUnsupportedSpaceTypes {
diff --git a/pkg/storage/registry/spaces/spaces.go b/pkg/storage/registry/spaces/spaces.go
index 1ad2fdf0e1f..8b36d1d924b 100644
--- a/pkg/storage/registry/spaces/spaces.go
+++ b/pkg/storage/registry/spaces/spaces.go
@@ -269,10 +269,21 @@ func (r *registry) ListProviders(ctx context.Context, filters map[string]string)
unrestricted, _ := strconv.ParseBool(filters["unrestricted"])
mask := filters["mask"]
switch {
- case filters["storage_id"] != "" && filters["opaque_id"] != "":
+ case filters["space_id"] != "":
+
findMountpoint := filters["type"] == "mountpoint"
- findGrant := !findMountpoint && filters["path"] == "" // relvative references, by definition, occur in the correct storage, so do not look for grants
- return r.findProvidersForResource(ctx, filters["storage_id"]+"!"+filters["opaque_id"], findMountpoint, findGrant, unrestricted, mask), nil
+ findGrant := !findMountpoint && filters["path"] == "" // relative references, by definition, occur in the correct storage, so do not look for grants
+ // If opaque_id is empty, we assume that we are looking for a space root
+ if filters["opaque_id"] == "" {
+ filters["opaque_id"] = filters["space_id"]
+ }
+ id := storagespace.FormatResourceID(providerpb.ResourceId{
+ StorageId: filters["storage_id"],
+ SpaceId: filters["space_id"],
+ OpaqueId: filters["opaque_id"],
+ })
+
+ return r.findProvidersForResource(ctx, id, findMountpoint, findGrant, unrestricted, mask), nil
case filters["path"] != "":
return r.findProvidersForAbsolutePathReference(ctx, filters["path"], b, unrestricted, mask), nil
case len(filters) == 0:
@@ -387,13 +398,12 @@ func (r *registry) findProvidersForFilter(ctx context.Context, filters []*provid
}
// findProvidersForResource looks up storage providers based on a resource id
-// for the root of a space the res.StorageId is the same as the res.OpaqueId
-// for share spaces the res.StorageId tells the registry the spaceid and res.OpaqueId is a node in that space
+// for the root of a space the res.SpaceId is the same as the res.OpaqueId
+// for share spaces the res.SpaceId tells the registry the spaceid and res.OpaqueId is a node in that space
func (r *registry) findProvidersForResource(ctx context.Context, id string, findMoundpoint, findGrant, unrestricted bool, mask string) []*registrypb.ProviderInfo {
currentUser := ctxpkg.ContextMustGetUser(ctx)
providerInfos := []*registrypb.ProviderInfo{}
- providerID, spaceID := storagespace.SplitStorageID(id)
- spaceID, nodeID, err := storagespace.SplitID(spaceID)
+ rid, err := storagespace.ParseID(id)
if err != nil {
appctx.GetLogger(ctx).Error().Err(err).Msg("splitting spaceid failed")
return nil
@@ -402,21 +412,18 @@ func (r *registry) findProvidersForResource(ctx context.Context, id string, find
for address, provider := range r.c.Providers {
p := ®istrypb.ProviderInfo{
Address: address,
- ProviderId: providerID,
+ ProviderId: rid.StorageId,
}
// try to find provider based on storageproviderid prefix if only root is requested
- if provider.ProviderID != "" && providerID != "" && mask == "root" {
- match, err := regexp.MatchString("^"+provider.ProviderID+"$", providerID)
+ if provider.ProviderID != "" && rid.StorageId != "" && mask == "root" {
+ match, err := regexp.MatchString("^"+provider.ProviderID+"$", rid.StorageId)
if err != nil || !match {
continue
}
// construct space based on configured properties without actually making a ListStorageSpaces call
space := &providerpb.StorageSpace{
- Id: &providerpb.StorageSpaceId{OpaqueId: id},
- Root: &providerpb.ResourceId{
- StorageId: spaceID,
- OpaqueId: nodeID,
- },
+ Id: &providerpb.StorageSpaceId{OpaqueId: id},
+ Root: &rid,
}
// this is a request for requests by id
// setPath(space, provider.Path) // hmm not enough info to build a path.... the space alias is no longer known here we would need to query the provider
@@ -429,8 +436,8 @@ func (r *registry) findProvidersForResource(ctx context.Context, id string, find
providerInfos = append(providerInfos, p)
return providerInfos
}
- if provider.ProviderID != "" && providerID != "" {
- match, err := regexp.MatchString("^"+provider.ProviderID+"$", providerID)
+ if provider.ProviderID != "" && rid.StorageId != "" {
+ match, err := regexp.MatchString("^"+provider.ProviderID+"$", rid.StorageId)
if err != nil || !match {
// skip mismatching storageproviders
continue
diff --git a/pkg/storage/registry/spaces/spaces_test.go b/pkg/storage/registry/spaces/spaces_test.go
index f4ec10d5e80..bd623ce69fd 100644
--- a/pkg/storage/registry/spaces/spaces_test.go
+++ b/pkg/storage/registry/spaces/spaces_test.go
@@ -30,6 +30,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage"
"github.com/cs3org/reva/v2/pkg/storage/registry/spaces"
"github.com/cs3org/reva/v2/pkg/storage/registry/spaces/mocks"
+ "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"
@@ -64,17 +65,18 @@ var _ = Describe("Spaces", func() {
fooClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(
func(_ context.Context, req *provider.ListStorageSpacesRequest, _ ...grpc.CallOption) *provider.ListStorageSpacesResponse {
+ rid := provider.ResourceId{StorageId: "provider-1", SpaceId: "foospace", OpaqueId: "foospace"}
spaces := []*provider.StorageSpace{
{
- Id: &provider.StorageSpaceId{OpaqueId: "foospace"},
- Root: &provider.ResourceId{StorageId: "foospace", OpaqueId: "foospace"},
+ Id: &provider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(rid)},
+ Root: &rid,
Name: "Foo space",
SpaceType: "personal",
Owner: alice,
},
}
for _, f := range req.Filters {
- if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID && f.GetId().OpaqueId != "foospace!foospace" {
+ if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID && f.GetId().OpaqueId != "provider-1$foospace!foospace" {
spaces = []*provider.StorageSpace{}
}
}
@@ -85,10 +87,11 @@ var _ = Describe("Spaces", func() {
}, nil)
barClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(
func(_ context.Context, req *provider.ListStorageSpacesRequest, _ ...grpc.CallOption) *provider.ListStorageSpacesResponse {
+ rid := provider.ResourceId{StorageId: "provider-1", SpaceId: "barspace", OpaqueId: "barspace"}
spaces := []*provider.StorageSpace{
{
- Id: &provider.StorageSpaceId{OpaqueId: "barspace"},
- Root: &provider.ResourceId{StorageId: "barspace", OpaqueId: "barspace"},
+ Id: &provider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(rid)},
+ Root: &rid,
Name: "Bar space",
SpaceType: "personal",
Owner: alice,
@@ -106,16 +109,18 @@ var _ = Describe("Spaces", func() {
}, nil)
bazClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(
func(_ context.Context, req *provider.ListStorageSpacesRequest, _ ...grpc.CallOption) *provider.ListStorageSpacesResponse {
+ rid1 := provider.ResourceId{StorageId: "provider-1", SpaceId: "bazspace1", OpaqueId: "bazspace1"}
+ rid2 := provider.ResourceId{StorageId: "provider-1", SpaceId: "bazspace2", OpaqueId: "bazspace2"}
space1 := &provider.StorageSpace{
- Id: &provider.StorageSpaceId{OpaqueId: "bazspace1"},
- Root: &provider.ResourceId{StorageId: "bazspace1", OpaqueId: "bazspace1"},
+ Id: &provider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(rid1)},
+ Root: &rid1,
Name: "Baz space 1",
SpaceType: "project",
Owner: alice,
}
space2 := &provider.StorageSpace{
- Id: &provider.StorageSpaceId{OpaqueId: "bazspace2"},
- Root: &provider.ResourceId{StorageId: "bazspace2", OpaqueId: "bazspace2"},
+ Id: &provider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(rid2)},
+ Root: &rid2,
Name: "Baz space 2",
SpaceType: "project",
Owner: alice,
@@ -123,9 +128,9 @@ var _ = Describe("Spaces", func() {
spaces := []*provider.StorageSpace{space1, space2}
for _, f := range req.Filters {
if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID {
- if f.GetId().OpaqueId == "bazspace1!bazspace1" {
+ if f.GetId().OpaqueId == "provider-1$bazspace1!bazspace1" {
spaces = []*provider.StorageSpace{space1}
- } else if f.GetId().OpaqueId == "bazspace2!bazspace2" {
+ } else if f.GetId().OpaqueId == "provider-1$bazspace2!bazspace2" {
spaces = []*provider.StorageSpace{space2}
} else {
spaces = []*provider.StorageSpace{}
@@ -307,10 +312,10 @@ var _ = Describe("Spaces", func() {
for _, space := range spaces {
spacePath := string(space.Opaque.Map["path"].Value)
switch space.Id.OpaqueId {
- case "bazspace1":
+ case "provider-1$bazspace1!bazspace1":
baz1Found = true
Expect(spacePath).To(Equal("/projects/Baz space 1"))
- case "bazspace2":
+ case "provider-1$bazspace2!bazspace2":
baz2Found = true
Expect(spacePath).To(Equal("/projects/Baz space 2"))
default:
@@ -324,6 +329,7 @@ var _ = Describe("Spaces", func() {
It("returns an empty list when a non-existent id is given", func() {
filters := map[string]string{
"storage_id": "invalid",
+ "space_id": "invalid",
"opaque_id": "barspace",
}
providers, err := handler.ListProviders(ctxAlice, filters)
@@ -333,7 +339,8 @@ var _ = Describe("Spaces", func() {
It("filters by id", func() {
filters := map[string]string{
- "storage_id": "foospace",
+ "storage_id": "provider-1",
+ "space_id": "foospace",
"opaque_id": "foospace",
}
providers, err := handler.ListProviders(ctxAlice, filters)
@@ -347,13 +354,14 @@ var _ = Describe("Spaces", func() {
Expect(err).ToNot(HaveOccurred())
Expect(len(spaces)).To(Equal(1))
- Expect(spaces[0].Id.OpaqueId).To(Equal("foospace"))
+ Expect(spaces[0].Id.OpaqueId).To(Equal("provider-1$foospace!foospace"))
Expect(spaces[0].Opaque.Map["path"].Decoder).To(Equal("plain"))
spacePath := string(spaces[0].Opaque.Map["path"].Value)
Expect(spacePath).To(Equal("/users/alice"))
filters = map[string]string{
- "storage_id": "bazspace2",
+ "storage_id": "provider-1",
+ "space_id": "bazspace2",
"opaque_id": "bazspace2",
}
providers, err = handler.ListProviders(ctxAlice, filters)
@@ -365,7 +373,7 @@ var _ = Describe("Spaces", func() {
err = json.Unmarshal(p.Opaque.Map["spaces"].Value, &spaces)
Expect(err).ToNot(HaveOccurred())
Expect(len(spaces)).To(Equal(1))
- Expect(spaces[0].Id.OpaqueId).To(Equal("bazspace2"))
+ Expect(spaces[0].Id.OpaqueId).To(Equal("provider-1$bazspace2!bazspace2"))
Expect(spaces[0].Opaque.Map["path"].Decoder).To(Equal("plain"))
spacePath = string(spaces[0].Opaque.Map["path"].Value)
Expect(spacePath).To(Equal("/projects/Baz space 2"))
diff --git a/pkg/storage/utils/decomposedfs/lookup/lookup.go b/pkg/storage/utils/decomposedfs/lookup/lookup.go
index 9acd721e614..da19dc14d6e 100644
--- a/pkg/storage/utils/decomposedfs/lookup/lookup.go
+++ b/pkg/storage/utils/decomposedfs/lookup/lookup.go
@@ -55,7 +55,7 @@ func (lu *Lookup) NodeFromResource(ctx context.Context, ref *provider.Reference)
if err != nil {
return nil, err
}
- n.SpaceID = ref.ResourceId.StorageId
+ n.SpaceID = ref.ResourceId.SpaceId
}
}
return n, nil
@@ -74,7 +74,7 @@ func (lu *Lookup) NodeFromID(ctx context.Context, id *provider.ResourceId) (n *n
// The Resource references the root of a space
return lu.NodeFromSpaceID(ctx, id)
}
- return node.ReadNode(ctx, lu, id.StorageId, id.OpaqueId, false)
+ return node.ReadNode(ctx, lu, id.SpaceId, id.OpaqueId, false)
}
// Pathify segments the beginning of a string into depth segments of width length
@@ -95,7 +95,7 @@ func Pathify(id string, depth, width int) string {
// NodeFromSpaceID converts a resource id without an opaque id into a Node
func (lu *Lookup) NodeFromSpaceID(ctx context.Context, id *provider.ResourceId) (n *node.Node, err error) {
- node, err := node.ReadNode(ctx, lu, id.StorageId, id.StorageId, false)
+ node, err := node.ReadNode(ctx, lu, id.SpaceId, id.OpaqueId, false)
if err != nil {
return nil, err
}
diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go
index 1f3ebb4c35f..5a51ce6e53a 100644
--- a/pkg/storage/utils/decomposedfs/node/node.go
+++ b/pkg/storage/utils/decomposedfs/node/node.go
@@ -614,7 +614,7 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi
// nodeType = provider.ResourceType_RESOURCE_TYPE_REFERENCE
}
- id := &provider.ResourceId{StorageId: n.SpaceID, OpaqueId: n.ID}
+ id := &provider.ResourceId{SpaceId: n.SpaceID, OpaqueId: n.ID}
if returnBasename {
fn = n.Name
@@ -628,8 +628,8 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi
var parentID *provider.ResourceId
if p, err := n.Parent(); err == nil {
parentID = &provider.ResourceId{
- StorageId: p.SpaceID,
- OpaqueId: p.ID,
+ SpaceId: p.SpaceID,
+ OpaqueId: p.ID,
}
}
diff --git a/pkg/storage/utils/decomposedfs/recycle.go b/pkg/storage/utils/decomposedfs/recycle.go
index bc25cb4a01d..e01fd632104 100644
--- a/pkg/storage/utils/decomposedfs/recycle.go
+++ b/pkg/storage/utils/decomposedfs/recycle.go
@@ -257,7 +257,7 @@ func (fs *Decomposedfs) RestoreRecycleItem(ctx context.Context, ref *provider.Re
targetNode = tn
}
- rn, parent, restoreFunc, err := fs.tp.RestoreRecycleItemFunc(ctx, ref.ResourceId.OpaqueId, key, relativePath, targetNode)
+ rn, parent, restoreFunc, err := fs.tp.RestoreRecycleItemFunc(ctx, ref.ResourceId.SpaceId, key, relativePath, targetNode)
if err != nil {
return err
}
@@ -335,7 +335,7 @@ func (fs *Decomposedfs) EmptyRecycle(ctx context.Context, ref *provider.Referenc
}
// TODO what permission should we check? we could check the root node of the user? or the owner permissions on his home root node?
// The current impl will wipe your own trash. or when no user provided the trash of 'root'
- return os.RemoveAll(fs.getRecycleRoot(ctx, ref.ResourceId.StorageId))
+ return os.RemoveAll(fs.getRecycleRoot(ctx, ref.ResourceId.SpaceId))
}
func getResourceType(isDir bool) provider.ResourceType {
diff --git a/pkg/storage/utils/decomposedfs/recycle_test.go b/pkg/storage/utils/decomposedfs/recycle_test.go
index 67b5bb7b38a..73e91aaeae2 100644
--- a/pkg/storage/utils/decomposedfs/recycle_test.go
+++ b/pkg/storage/utils/decomposedfs/recycle_test.go
@@ -290,7 +290,7 @@ var _ = Describe("Recycle", func() {
Expect(len(items)).To(Equal(1))
// use up 2000 byte quota
- _, err = env.CreateTestFile("largefile", "largefile-blobid", projectID.OpaqueId, projectID.StorageId, 2000)
+ _, err = env.CreateTestFile("largefile", "largefile-blobid", projectID.OpaqueId, projectID.SpaceId, 2000)
Expect(err).ToNot(HaveOccurred())
err = env.Fs.RestoreRecycleItem(env.Ctx, &provider.Reference{ResourceId: projectID}, items[0].Key, "/", nil)
diff --git a/pkg/storage/utils/decomposedfs/revisions.go b/pkg/storage/utils/decomposedfs/revisions.go
index 37cd90fa565..e2c1479a112 100644
--- a/pkg/storage/utils/decomposedfs/revisions.go
+++ b/pkg/storage/utils/decomposedfs/revisions.go
@@ -107,7 +107,7 @@ func (fs *Decomposedfs) DownloadRevision(ctx context.Context, ref *provider.Refe
}
log.Debug().Str("revisionKey", revisionKey).Msg("DownloadRevision")
- spaceID := ref.ResourceId.OpaqueId
+ spaceID := ref.ResourceId.SpaceId
// check if the node is available and has not been deleted
n, err := node.ReadNode(ctx, fs.lu, spaceID, kp[0], false)
if err != nil {
@@ -152,7 +152,7 @@ func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Refer
return errtypes.NotFound(revisionKey)
}
- spaceID := ref.ResourceId.StorageId
+ spaceID := ref.ResourceId.SpaceId
// check if the node is available and has not been deleted
n, err := node.ReadNode(ctx, fs.lu, spaceID, kp[0], false)
if err != nil {
diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go
index 52a9e4a06c7..adf3ae726b8 100644
--- a/pkg/storage/utils/decomposedfs/spaces.go
+++ b/pkg/storage/utils/decomposedfs/spaces.go
@@ -144,8 +144,8 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
u := ctxpkg.ContextMustGetUser(ctx)
if err := fs.AddGrant(ctx, &provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: spaceID,
- OpaqueId: spaceID,
+ SpaceId: spaceID,
+ OpaqueId: spaceID,
},
}, &provider.Grant{
Grantee: &provider.Grantee{
@@ -266,7 +266,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
spaceTypes = append(spaceTypes, filter[i].GetSpaceType())
}
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- spaceID, nodeID, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
+ _, spaceID, nodeID, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
if strings.Contains(nodeID, "/") {
return []*provider.StorageSpace{}, nil
}
@@ -403,7 +403,7 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up
}
space := req.StorageSpace
- spaceID, _, _ := storagespace.SplitID(space.Id.OpaqueId)
+ _, spaceID, _, _ := storagespace.SplitID(space.Id.OpaqueId)
node, err := node.ReadNode(ctx, fs.lu, spaceID, spaceID, true) // permission to read disabled space will be checked later
if err != nil {
@@ -632,8 +632,8 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node,
ssID, err := storagespace.FormatReference(
&provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: n.SpaceRoot.SpaceID,
- OpaqueId: n.ID},
+ SpaceId: n.SpaceRoot.SpaceID,
+ OpaqueId: n.ID},
},
)
if err != nil {
@@ -650,8 +650,8 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node,
},
Id: &provider.StorageSpaceId{OpaqueId: ssID},
Root: &provider.ResourceId{
- StorageId: n.SpaceRoot.SpaceID,
- OpaqueId: n.ID,
+ SpaceId: n.SpaceRoot.SpaceID,
+ OpaqueId: n.ID,
},
Name: sname,
// SpaceType is read from xattr below
@@ -726,7 +726,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node,
spaceImage, ok := spaceAttributes[xattrs.SpaceImageAttr]
if ok {
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "image", storagespace.FormatResourceID(
- provider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: spaceImage},
+ provider.ResourceId{StorageId: space.Root.StorageId, SpaceId: space.Root.SpaceId, OpaqueId: spaceImage},
))
}
spaceDescription, ok := spaceAttributes[xattrs.SpaceDescriptionAttr]
@@ -736,7 +736,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node,
spaceReadme, ok := spaceAttributes[xattrs.SpaceReadmeAttr]
if ok {
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "readme", storagespace.FormatResourceID(
- provider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: spaceReadme},
+ provider.ResourceId{StorageId: space.Root.StorageId, SpaceId: space.Root.SpaceId, OpaqueId: spaceReadme},
))
}
spaceAlias, ok := spaceAttributes[xattrs.SpaceAliasAttr]
diff --git a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go
index 69383710999..ee4f9baebaf 100644
--- a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go
+++ b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go
@@ -210,7 +210,7 @@ func (t *TestEnv) CreateTestStorageSpace(typ string, quota *providerv1beta1.Quot
if err != nil {
return nil, err
}
- h, err := node.ReadNode(t.Ctx, t.Lookup, sid.StorageId, sid.OpaqueId, false)
+ h, err := node.ReadNode(t.Ctx, t.Lookup, sid.SpaceId, sid.OpaqueId, false)
if err != nil {
return nil, err
}
@@ -264,6 +264,7 @@ func buildRef(id, path string) *providerv1beta1.Reference {
return &providerv1beta1.Reference{
ResourceId: &providerv1beta1.ResourceId{
StorageId: res.StorageId,
+ SpaceId: res.SpaceId,
OpaqueId: res.OpaqueId,
},
Path: path,
diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go
index 2e21b77d06c..4ab784a751f 100644
--- a/pkg/storage/utils/decomposedfs/tree/tree.go
+++ b/pkg/storage/utils/decomposedfs/tree/tree.go
@@ -511,7 +511,7 @@ func (t *Tree) RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPa
}
targetRef := &provider.Reference{
- ResourceId: &provider.ResourceId{StorageId: spaceid, OpaqueId: spaceid},
+ ResourceId: &provider.ResourceId{SpaceId: spaceid, OpaqueId: spaceid},
Path: utils.MakeRelativePath(origin),
}
diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go
index 82e3e79e729..3e6c01e20ff 100644
--- a/pkg/storage/utils/decomposedfs/upload.go
+++ b/pkg/storage/utils/decomposedfs/upload.go
@@ -46,7 +46,6 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/lookup"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/xattrs"
- "github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -102,7 +101,8 @@ func (fs *Decomposedfs) Upload(ctx context.Context, ref *provider.Reference, r i
info := uploadInfo.info
uploadRef := &provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: storagespace.FormatStorageID(info.MetaData["providerID"], info.Storage["SpaceRoot"]),
+ StorageId: info.MetaData["providerID"],
+ SpaceId: info.Storage["SpaceRoot"],
OpaqueId: info.Storage["SpaceRoot"],
},
Path: utils.MakeRelativePath(filepath.Join(info.MetaData["dir"], info.MetaData["filename"])),
@@ -220,7 +220,8 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo
}
n, err := fs.lu.NodeFromSpaceID(ctx, &provider.ResourceId{
- StorageId: info.Storage["SpaceRoot"],
+ SpaceId: info.Storage["SpaceRoot"],
+ OpaqueId: info.Storage["SpaceRoot"],
})
if err != nil {
return nil, errors.Wrap(err, "Decomposedfs: error getting space root node")
diff --git a/pkg/storage/utils/decomposedfs/upload_test.go b/pkg/storage/utils/decomposedfs/upload_test.go
index 5f4276ed5bb..4e0c1567627 100644
--- a/pkg/storage/utils/decomposedfs/upload_test.go
+++ b/pkg/storage/utils/decomposedfs/upload_test.go
@@ -67,7 +67,7 @@ var _ = Describe("File uploads", func() {
BeforeEach(func() {
ref = &provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: "u-s-e-r-id",
+ SpaceId: "u-s-e-r-id",
},
Path: "/foo",
}
@@ -83,7 +83,8 @@ var _ = Describe("File uploads", func() {
rootRef = &provider.Reference{
ResourceId: &provider.ResourceId{
- StorageId: "u-s-e-r-id",
+ SpaceId: "u-s-e-r-id",
+ OpaqueId: "u-s-e-r-id",
},
Path: "/",
}
@@ -124,7 +125,7 @@ var _ = Describe("File uploads", func() {
Expect(resp.Status.Code).To(Equal(v1beta11.Code_CODE_OK))
resID, err := storagespace.ParseID(resp.StorageSpace.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
- ref.ResourceId = &provider.ResourceId{StorageId: resID.StorageId, OpaqueId: resID.OpaqueId}
+ ref.ResourceId = &resID
})
Context("the user's quota is exceeded", func() {
diff --git a/pkg/storage/utils/eosfs/spaces.go b/pkg/storage/utils/eosfs/spaces.go
index 78d1cc20a0f..494bfc6f212 100644
--- a/pkg/storage/utils/eosfs/spaces.go
+++ b/pkg/storage/utils/eosfs/spaces.go
@@ -73,7 +73,7 @@ func (fs *eosfs) ListStorageSpaces(ctx context.Context, filter []*provider.ListS
for i := range filter {
switch filter[i].Type {
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
- spaceID, _, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
+ _, spaceID, _, _ = storagespace.SplitID(filter[i].GetId().OpaqueId)
case provider.ListStorageSpacesRequest_Filter_TYPE_PATH:
spacePath = filter[i].GetPath()
case provider.ListStorageSpacesRequest_Filter_TYPE_SPACE_TYPE:
diff --git a/pkg/storage/utils/metadata/cs3.go b/pkg/storage/utils/metadata/cs3.go
index fcb41025ad0..f8ae1157ef5 100644
--- a/pkg/storage/utils/metadata/cs3.go
+++ b/pkg/storage/utils/metadata/cs3.go
@@ -104,7 +104,7 @@ func (cs3 *CS3) Init(ctx context.Context, spaceid string) (err error) {
cs3.SpaceRoot = cssr.StorageSpace.Root
case cssr.Status.Code == rpc.Code_CODE_ALREADY_EXISTS:
// TODO make CreateStorageSpace return existing space?
- cs3.SpaceRoot = &provider.ResourceId{StorageId: spaceid, OpaqueId: spaceid}
+ cs3.SpaceRoot = &provider.ResourceId{SpaceId: spaceid, OpaqueId: spaceid}
default:
return errtypes.NewErrtypeFromStatus(cssr.Status)
}
diff --git a/pkg/storagespace/storagespace.go b/pkg/storagespace/storagespace.go
index e24423e9319..1988192c08d 100644
--- a/pkg/storagespace/storagespace.go
+++ b/pkg/storagespace/storagespace.go
@@ -140,7 +140,6 @@ func FormatReference(ref *provider.Reference) (string, error) {
if ref == nil || ref.ResourceId == nil || ref.ResourceId.SpaceId == "" {
return "", ErrInvalidSpaceReference
}
- var ssid string
- ssid = FormatResourceID(*ref.ResourceId)
+ ssid := FormatResourceID(*ref.ResourceId)
return path.Join(ssid, ref.Path), nil
}
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
index d251f31df87..c9a41026c97 100644
--- a/pkg/utils/utils.go
+++ b/pkg/utils/utils.go
@@ -55,8 +55,10 @@ var (
// ShareStorageSpaceID is the space id used by the sharestorageprovider share jail space
ShareStorageSpaceID = "a0ca6a90-a365-4782-871e-d44447bbc668"
- // PublicStorageProviderID is the id used by the sharestorageprovider
+ // PublicStorageProviderID is the storage id used by the sharestorageprovider
PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4"
+ // PublicStorageSpaceID is the space id used by the sharestorageprovider
+ PublicStorageSpaceID = "7993447f-687f-490d-875c-ac95e89a62a4"
// SpaceGrant is used to signal the storageprovider that the grant is on a space
SpaceGrant struct{}
diff --git a/tests/integration/grpc/gateway_storageprovider_test.go b/tests/integration/grpc/gateway_storageprovider_test.go
index 100bc947d79..f73dc19958a 100644
--- a/tests/integration/grpc/gateway_storageprovider_test.go
+++ b/tests/integration/grpc/gateway_storageprovider_test.go
@@ -68,8 +68,8 @@ var _ = Describe("gateway", func() {
}
homeRef = &storagep.Reference{
ResourceId: &storagep.ResourceId{
- StorageId: user.Id.OpaqueId,
- OpaqueId: user.Id.OpaqueId,
+ SpaceId: user.Id.OpaqueId,
+ OpaqueId: user.Id.OpaqueId,
},
Path: ".",
}
@@ -197,7 +197,7 @@ var _ = Describe("gateway", func() {
Expect(err).ToNot(HaveOccurred())
err = helpers.Upload(ctx,
shard1Fs,
- &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: ssid.StorageId}, Path: "/file.txt"},
+ &storagep.Reference{ResourceId: &ssid, Path: "/file.txt"},
[]byte("1"),
)
Expect(err).ToNot(HaveOccurred())
@@ -308,9 +308,9 @@ var _ = Describe("gateway", func() {
Expect(listRes.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK))
ssid, err := storagespace.ParseID(space.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
- _, err = os.Stat(path.Join(revads["storage"].StorageRoot, "/spacetypes/project", ssid.StorageId))
+ _, err = os.Stat(path.Join(revads["storage"].StorageRoot, "/spacetypes/project", ssid.SpaceId))
Expect(err).To(HaveOccurred())
- _, err = os.Stat(path.Join(revads["storage2"].StorageRoot, "/spacetypes/project", ssid.StorageId))
+ _, err = os.Stat(path.Join(revads["storage2"].StorageRoot, "/spacetypes/project", ssid.SpaceId))
Expect(err).ToNot(HaveOccurred())
})
@@ -384,7 +384,7 @@ var _ = Describe("gateway", func() {
Expect(err).ToNot(HaveOccurred())
err = helpers.Upload(ctx,
fs,
- &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: ssid.StorageId}, Path: "/file.txt"},
+ &storagep.Reference{ResourceId: &ssid, Path: "/file.txt"},
[]byte("1"),
)
Expect(err).ToNot(HaveOccurred())
@@ -409,15 +409,12 @@ var _ = Describe("gateway", func() {
essid, err := storagespace.ParseID(embeddedSpace.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
embeddedRef = &storagep.Reference{
- ResourceId: &storagep.ResourceId{
- StorageId: essid.StorageId,
- OpaqueId: essid.OpaqueId,
- },
- Path: ".", // path.Join(homeRef.Path, "Projects", embeddedSpace.Id.OpaqueId),
+ ResourceId: &essid,
+ Path: ".", // path.Join(homeRef.Path, "Projects", embeddedSpace.Id.OpaqueId),
}
err = helpers.Upload(ctx,
embeddedFs,
- &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: essid.StorageId}, Path: "/embedded.txt"},
+ &storagep.Reference{ResourceId: &essid, Path: "/embedded.txt"},
[]byte("22"),
)
Expect(err).ToNot(HaveOccurred())
@@ -507,7 +504,9 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(3)))
By("Uploading a new file")
- err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: homeSpace.Id.OpaqueId}, Path: "/newfile.txt"}, []byte("1234567890"))
+ rid, err := storagespace.ParseID(homeSpace.Id.OpaqueId)
+ Expect(err).ToNot(HaveOccurred())
+ err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &rid, Path: "/newfile.txt"}, []byte("1234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -517,9 +516,9 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(13)))
By("Uploading a new file into a subdir")
- err = fs.CreateDir(ctx, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: homeSpace.Id.OpaqueId}, Path: "/newdir"})
+ err = fs.CreateDir(ctx, &storagep.Reference{ResourceId: &rid, Path: "/newdir"})
Expect(err).ToNot(HaveOccurred())
- err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: homeSpace.Id.OpaqueId}, Path: "/newdir/newfile.txt"}, []byte("1234567890"))
+ err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &rid, Path: "/newdir/newfile.txt"}, []byte("1234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -529,7 +528,7 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(23)))
By("Updating an existing file")
- err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: homeSpace.Id.OpaqueId}, Path: "/newdir/newfile.txt"}, []byte("12345678901234567890"))
+ err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &rid, Path: "/newdir/newfile.txt"}, []byte("12345678901234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -546,7 +545,9 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(3)))
By("Uploading a new file")
- err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: embeddedSpace.Id.OpaqueId}, Path: "/newfile.txt"}, []byte("1234567890"))
+ rid, err := storagespace.ParseID(embeddedSpace.Id.OpaqueId)
+ Expect(err).ToNot(HaveOccurred())
+ err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &rid, Path: "/newfile.txt"}, []byte("1234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -556,9 +557,9 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(13)))
By("Uploading a new file into a subdir")
- err = embeddedFs.CreateDir(ctx, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: embeddedSpace.Id.OpaqueId}, Path: "/newdir"})
+ err = embeddedFs.CreateDir(ctx, &storagep.Reference{ResourceId: &rid, Path: "/newdir"})
Expect(err).ToNot(HaveOccurred())
- err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: embeddedSpace.Id.OpaqueId}, Path: "/newdir/newfile.txt"}, []byte("1234567890"))
+ err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &rid, Path: "/newdir/newfile.txt"}, []byte("1234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -568,7 +569,7 @@ var _ = Describe("gateway", func() {
Expect(statRes.Info.Size).To(Equal(uint64(23)))
By("Updating an existing file")
- err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: embeddedSpace.Id.OpaqueId}, Path: "/newdir/newfile.txt"}, []byte("12345678901234567890"))
+ err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &rid, Path: "/newdir/newfile.txt"}, []byte("12345678901234567890"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -586,7 +587,7 @@ var _ = Describe("gateway", func() {
ssid, err := storagespace.ParseID(homeSpace.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
By("Uploading a new file")
- err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: ssid.StorageId}, Path: "/newfile.txt"}, []byte("1"))
+ err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &ssid, Path: "/newfile.txt"}, []byte("1"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -598,7 +599,7 @@ var _ = Describe("gateway", func() {
Expect(newEtag).ToNot(Equal(etag))
By("Creating a new dir")
- err = fs.CreateDir(ctx, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: ssid.StorageId}, Path: "/newdir"})
+ err = fs.CreateDir(ctx, &storagep.Reference{ResourceId: &ssid, Path: "/newdir"})
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -610,7 +611,7 @@ var _ = Describe("gateway", func() {
Expect(newEtag2).ToNot(Equal(newEtag))
By("Updating an existing file")
- err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: ssid.StorageId}, Path: "/file.txt"}, []byte("2"))
+ err = helpers.Upload(ctx, fs, &storagep.Reference{ResourceId: &ssid, Path: "/file.txt"}, []byte("2"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -630,7 +631,7 @@ var _ = Describe("gateway", func() {
essid, err := storagespace.ParseID(embeddedSpace.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
By("Uploading a new file")
- err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: essid.StorageId}, Path: "/newfile.txt"}, []byte("1"))
+ err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &essid, Path: "/newfile.txt"}, []byte("1"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -642,7 +643,7 @@ var _ = Describe("gateway", func() {
Expect(newEtag).ToNot(Equal(etag))
By("Creating a new dir")
- err = embeddedFs.CreateDir(ctx, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: essid.StorageId}, Path: "/newdir"})
+ err = embeddedFs.CreateDir(ctx, &storagep.Reference{ResourceId: &essid, Path: "/newdir"})
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -654,7 +655,7 @@ var _ = Describe("gateway", func() {
Expect(newEtag2).ToNot(Equal(newEtag))
By("Updating an existing file")
- err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: essid.StorageId}, Path: "/newfile.txt"}, []byte("1"))
+ err = helpers.Upload(ctx, embeddedFs, &storagep.Reference{ResourceId: &essid, Path: "/newfile.txt"}, []byte("1"))
Expect(err).ToNot(HaveOccurred())
time.Sleep(time.Second) // cache must expire
@@ -671,9 +672,9 @@ var _ = Describe("gateway", func() {
It("moves a directory", func() {
hssid, err := storagespace.ParseID(homeSpace.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
- sourceRef := &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: hssid.StorageId, OpaqueId: hssid.OpaqueId}, Path: "./source"}
- targetRef := &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: hssid.StorageId, OpaqueId: hssid.OpaqueId}, Path: "./destination"}
- dstRef := &storagep.Reference{ResourceId: &storagep.ResourceId{StorageId: hssid.StorageId, OpaqueId: hssid.OpaqueId}, Path: "./destination/source"}
+ sourceRef := &storagep.Reference{ResourceId: &hssid, Path: "./source"}
+ targetRef := &storagep.Reference{ResourceId: &hssid, Path: "./destination"}
+ dstRef := &storagep.Reference{ResourceId: &hssid, Path: "./destination/source"}
err = fs.CreateDir(ctx, sourceRef)
Expect(err).ToNot(HaveOccurred())
diff --git a/tests/integration/grpc/storageprovider_test.go b/tests/integration/grpc/storageprovider_test.go
index 863d62cb736..3887195d964 100644
--- a/tests/integration/grpc/storageprovider_test.go
+++ b/tests/integration/grpc/storageprovider_test.go
@@ -46,8 +46,8 @@ func ref(provider string, path string) *storagep.Reference {
}
if provider == "ocis" {
r.ResourceId = &storagep.ResourceId{
- StorageId: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
- OpaqueId: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
+ SpaceId: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
+ OpaqueId: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
}
}
return r
@@ -284,6 +284,7 @@ var _ = Describe("storage providers", func() {
Expect(err).ToNot(HaveOccurred())
// TODO: FIXME both cases should work for all providers
+
Expect(res.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK))
if provider != "nextcloud" {
Expect(res.Path).To(Equal(subdirPath))