From 196f80b845acc0b7625d4b3b747ebac85b4e7f55 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 16:32:22 +0200 Subject: [PATCH 01/18] get rid of interceptor and move logic to storageprovider Signed-off-by: jkoberg --- .../storageprovider/storageprovider.go | 172 +++++++++++++++++- 1 file changed, 167 insertions(+), 5 deletions(-) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index d81661273d..67de10d191 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -43,6 +43,7 @@ import ( "github.com/cs3org/reva/v2/pkg/storage/fs/registry" rtrace "github.com/cs3org/reva/v2/pkg/trace" "github.com/cs3org/reva/v2/pkg/utils" + "github.com/cs3org/reva/v2/pkg/utils/resourceid" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" "go.opentelemetry.io/otel/attribute" @@ -202,6 +203,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) err := s.storage.SetArbitraryMetadata(ctx, req.Ref, req.ArbitraryMetadata) @@ -212,6 +217,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) err := s.storage.UnsetArbitraryMetadata(ctx, req.Ref, req.ArbitraryMetadataKeys) @@ -223,6 +232,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + err := s.storage.SetLock(ctx, req.Ref, req.Lock) return &provider.SetLockResponse{ @@ -232,6 +245,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + lock, err := s.storage.GetLock(ctx, req.Ref) return &provider.GetLockResponse{ @@ -242,6 +259,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + err := s.storage.RefreshLock(ctx, req.Ref, req.Lock) return &provider.RefreshLockResponse{ @@ -251,6 +272,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + err := s.storage.Unlock(ctx, req.Ref, req.Lock) return &provider.UnlockResponse{ @@ -259,6 +284,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // 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. @@ -289,6 +318,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // TODO(labkode): same considerations as download log := appctx.GetLogger(ctx) if req.Ref.GetPath() == "/" { @@ -404,6 +437,10 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate } func (s *service) GetPath(ctx context.Context, req *provider.GetPathRequest) (*provider.GetPathResponse, error) { + if req.GetResourceId() != nil { + req.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.ResourceId.StorageId) + } + // 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 { @@ -472,6 +509,16 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt } func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) { + var providerID string + for i, f := range req.Filters { + if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID { + id, p := resourceid.StorageIDUnwrap(f.GetId().GetOpaqueId()) + req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Id{Id: &provider.StorageSpaceId{OpaqueId: id}} + providerID = p + break + } + } + log := appctx.GetLogger(ctx) spaces, err := s.storage.ListStorageSpaces(ctx, req.Filters) @@ -497,10 +544,13 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora }, nil } - for i := range spaces { - if spaces[i].Id == nil || spaces[i].Id.OpaqueId == "" { - log.Error().Str("service", "storageprovider").Str("driver", s.conf.Driver).Interface("space", spaces[i]).Msg("space is missing space id and root id") + for _, sp := range spaces { + if sp.Id == nil || sp.Id.OpaqueId == "" { + log.Error().Str("service", "storageprovider").Str("driver", s.conf.Driver).Interface("space", sp).Msg("space is missing space id and root id") + continue } + sp.Id.OpaqueId = resourceid.StorageIDWrap(sp.Id.GetOpaqueId(), providerID) + sp.Root.StorageId = resourceid.StorageIDWrap(sp.Id.GetOpaqueId(), providerID) } return &provider.ListStorageSpacesResponse{ @@ -510,6 +560,12 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora } func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorageSpaceRequest) (*provider.UpdateStorageSpaceResponse, error) { + var providerID string + if req.GetStorageSpace().GetId() != nil { + req.StorageSpace.Id.OpaqueId, providerID = resourceid.StorageIDUnwrap(req.StorageSpace.Id.OpaqueId) + req.StorageSpace.Root.StorageId, _ = resourceid.StorageIDUnwrap(req.StorageSpace.Root.StorageId) + } + res, err := s.storage.UpdateStorageSpace(ctx, req) if err != nil { appctx.GetLogger(ctx). @@ -519,10 +575,15 @@ func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateSt Msg("failed to update storage space") return nil, err } + res.StorageSpace.Id.OpaqueId = resourceid.StorageIDWrap(res.StorageSpace.Id.GetOpaqueId(), providerID) return res, nil } func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorageSpaceRequest) (*provider.DeleteStorageSpaceResponse, error) { + if req.GetId() != nil { + req.Id.OpaqueId, _ = resourceid.StorageIDUnwrap(req.Id.OpaqueId) + } + if err := s.storage.DeleteStorageSpace(ctx, req); err != nil { var st *rpc.Status switch err.(type) { @@ -553,6 +614,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // FIXME these should be part of the CreateContainerRequest object if req.Opaque != nil { if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" { @@ -568,6 +633,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // FIXME these should be part of the TouchFileRequest object if req.Opaque != nil { if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" { @@ -583,6 +652,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + if req.Ref.GetPath() == "/" { return &provider.DeleteResponse{ Status: status.NewInternal(ctx, "can't delete mount path"), @@ -608,6 +681,13 @@ 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, _ = resourceid.StorageIDUnwrap(req.Source.ResourceId.StorageId) + } + if req.Destination.GetResourceId() != nil { + req.Destination.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Destination.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) err := s.storage.Move(ctx, req.Source, req.Destination) @@ -618,6 +698,11 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide } func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) { + var providerID string + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx, span := rtrace.Provider.Tracer("reva").Start(ctx, "stat") defer span.End() @@ -627,14 +712,24 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide }) md, err := s.storage.GetMD(ctx, req.Ref, req.ArbitraryMetadataKeys) + if err != nil { + return &provider.StatResponse{ + Status: status.NewStatusFromErrType(ctx, "stat", err), + }, nil + } + md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), providerID) return &provider.StatResponse{ - Status: status.NewStatusFromErrType(ctx, "stat", err), + Status: status.NewOK(ctx), Info: md, }, nil } func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest, ss provider.ProviderAPI_ListContainerStreamServer) error { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx := ss.Context() log := appctx.GetLogger(ctx) @@ -679,16 +774,31 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest, } func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) { - mds, err := s.storage.ListFolder(ctx, req.Ref, req.ArbitraryMetadataKeys) + var providerID string + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + mds, err := s.storage.ListFolder(ctx, req.Ref, req.ArbitraryMetadataKeys) res := &provider.ListContainerResponse{ Status: status.NewStatusFromErrType(ctx, "list container", err), Infos: mds, } + if err != nil { + return res, nil + } + + for _, i := range res.Infos { + i.Id.StorageId = resourceid.StorageIDWrap(i.Id.GetStorageId(), providerID) + } return res, nil } func (s *service) ListFileVersions(ctx context.Context, req *provider.ListFileVersionsRequest) (*provider.ListFileVersionsResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + revs, err := s.storage.ListRevisions(ctx, req.Ref) sort.Sort(descendingMtime(revs)) @@ -700,6 +810,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) err := s.storage.RestoreRevision(ctx, req.Ref, req.Key) @@ -710,6 +824,10 @@ func (s *service) RestoreFileVersion(ctx context.Context, req *provider.RestoreF } func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss provider.ProviderAPI_ListRecycleStreamServer) error { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx := ss.Context() log := appctx.GetLogger(ctx) @@ -756,6 +874,11 @@ func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss p } func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequest) (*provider.ListRecycleResponse, error) { + var providerID string + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + key, itemPath := router.ShiftPath(req.Key) items, err := s.storage.ListRecycle(ctx, req.Ref, key, itemPath) if err != nil { @@ -780,6 +903,9 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ }, nil } + for _, i := range items { + i.Ref.ResourceId.StorageId = resourceid.StorageIDWrap(i.Ref.GetResourceId().GetStorageId(), providerID) + } res := &provider.ListRecycleResponse{ Status: status.NewOK(ctx), RecycleItems: items, @@ -788,6 +914,10 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ } func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreRecycleItemRequest) (*provider.RestoreRecycleItemResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) // TODO(labkode): CRITICAL: fill recycle info with storage provider. @@ -801,6 +931,10 @@ func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreR } func (s *service) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleRequest) (*provider.PurgeRecycleResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // FIXME these should be part of the PurgeRecycleRequest object if req.Opaque != nil { if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" { @@ -846,6 +980,10 @@ func (s *service) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleRe } func (s *service) ListGrants(ctx context.Context, req *provider.ListGrantsRequest) (*provider.ListGrantsResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + grants, err := s.storage.ListGrants(ctx, req.Ref) if err != nil { var st *rpc.Status @@ -876,6 +1014,10 @@ func (s *service) ListGrants(ctx context.Context, req *provider.ListGrantsReques } func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest) (*provider.DenyGrantResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // check grantee type is valid if req.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_INVALID { return &provider.DenyGrantResponse{ @@ -917,6 +1059,10 @@ func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest) } func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (*provider.AddGrantResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) // TODO: update CS3 APIs @@ -943,6 +1089,10 @@ func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) ( } func (s *service) UpdateGrant(ctx context.Context, req *provider.UpdateGrantRequest) (*provider.UpdateGrantResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // FIXME these should be part of the UpdateGrantRequest object if req.Opaque != nil { if e, ok := req.Opaque.Map["lockid"]; ok && e.Decoder == "plain" { @@ -965,6 +1115,10 @@ func (s *service) UpdateGrant(ctx context.Context, req *provider.UpdateGrantRequ } func (s *service) RemoveGrant(ctx context.Context, req *provider.RemoveGrantRequest) (*provider.RemoveGrantResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) // check targetType is valid @@ -982,6 +1136,10 @@ func (s *service) RemoveGrant(ctx context.Context, req *provider.RemoveGrantRequ } func (s *service) CreateReference(ctx context.Context, req *provider.CreateReferenceRequest) (*provider.CreateReferenceResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + log := appctx.GetLogger(ctx) // parse uri is valid @@ -1025,6 +1183,10 @@ func (s *service) CreateSymlink(ctx context.Context, req *provider.CreateSymlink } func (s *service) GetQuota(ctx context.Context, req *provider.GetQuotaRequest) (*provider.GetQuotaResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + total, used, remaining, err := s.storage.GetQuota(ctx, req.Ref) if err != nil { var st *rpc.Status From 784dca35e4c19b658e723b004fcbefba469d6486 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 17:48:57 +0200 Subject: [PATCH 02/18] use configured mountID instead of requested one Signed-off-by: jkoberg --- .../storageprovider/storageprovider.go | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 67de10d191..10c8d5ba03 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -509,12 +509,10 @@ func (s *service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt } func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSpacesRequest) (*provider.ListStorageSpacesResponse, error) { - var providerID string for i, f := range req.Filters { if f.Type == provider.ListStorageSpacesRequest_Filter_TYPE_ID { - id, p := resourceid.StorageIDUnwrap(f.GetId().GetOpaqueId()) + id, _ := resourceid.StorageIDUnwrap(f.GetId().GetOpaqueId()) req.Filters[i].Term = &provider.ListStorageSpacesRequest_Filter_Id{Id: &provider.StorageSpaceId{OpaqueId: id}} - providerID = p break } } @@ -549,8 +547,8 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora log.Error().Str("service", "storageprovider").Str("driver", s.conf.Driver).Interface("space", sp).Msg("space is missing space id and root id") continue } - sp.Id.OpaqueId = resourceid.StorageIDWrap(sp.Id.GetOpaqueId(), providerID) - sp.Root.StorageId = resourceid.StorageIDWrap(sp.Id.GetOpaqueId(), providerID) + sp.Id.OpaqueId = resourceid.StorageIDWrap(sp.Id.GetOpaqueId(), s.conf.MountID) + sp.Root.StorageId = resourceid.StorageIDWrap(sp.Root.GetStorageId(), s.conf.MountID) } return &provider.ListStorageSpacesResponse{ @@ -560,9 +558,8 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora } func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorageSpaceRequest) (*provider.UpdateStorageSpaceResponse, error) { - var providerID string if req.GetStorageSpace().GetId() != nil { - req.StorageSpace.Id.OpaqueId, providerID = resourceid.StorageIDUnwrap(req.StorageSpace.Id.OpaqueId) + req.StorageSpace.Id.OpaqueId, _ = resourceid.StorageIDUnwrap(req.StorageSpace.Id.OpaqueId) req.StorageSpace.Root.StorageId, _ = resourceid.StorageIDUnwrap(req.StorageSpace.Root.StorageId) } @@ -575,7 +572,7 @@ func (s *service) UpdateStorageSpace(ctx context.Context, req *provider.UpdateSt Msg("failed to update storage space") return nil, err } - res.StorageSpace.Id.OpaqueId = resourceid.StorageIDWrap(res.StorageSpace.Id.GetOpaqueId(), providerID) + res.StorageSpace.Id.OpaqueId = resourceid.StorageIDWrap(res.StorageSpace.Id.GetOpaqueId(), s.conf.MountID) return res, nil } @@ -698,9 +695,8 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide } func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) { - var providerID string if req.Ref.GetResourceId() != nil { - req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) } ctx, span := rtrace.Provider.Tracer("reva").Start(ctx, "stat") @@ -718,7 +714,7 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide }, nil } - md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), providerID) + md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), s.conf.MountID) return &provider.StatResponse{ Status: status.NewOK(ctx), Info: md, @@ -774,9 +770,8 @@ func (s *service) ListContainerStream(req *provider.ListContainerStreamRequest, } func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) { - var providerID string if req.Ref.GetResourceId() != nil { - req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) } mds, err := s.storage.ListFolder(ctx, req.Ref, req.ArbitraryMetadataKeys) @@ -789,7 +784,7 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer } for _, i := range res.Infos { - i.Id.StorageId = resourceid.StorageIDWrap(i.Id.GetStorageId(), providerID) + i.Id.StorageId = resourceid.StorageIDWrap(i.Id.GetStorageId(), s.conf.MountID) } return res, nil } @@ -874,9 +869,8 @@ func (s *service) ListRecycleStream(req *provider.ListRecycleStreamRequest, ss p } func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequest) (*provider.ListRecycleResponse, error) { - var providerID string if req.Ref.GetResourceId() != nil { - req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) } key, itemPath := router.ShiftPath(req.Key) @@ -904,7 +898,7 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ } for _, i := range items { - i.Ref.ResourceId.StorageId = resourceid.StorageIDWrap(i.Ref.GetResourceId().GetStorageId(), providerID) + i.Ref.ResourceId.StorageId = resourceid.StorageIDWrap(i.Ref.GetResourceId().GetStorageId(), s.conf.MountID) } res := &provider.ListRecycleResponse{ Status: status.NewOK(ctx), From 68e490da751159e5989069fea75d496951200675 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 18:04:41 +0200 Subject: [PATCH 03/18] use requested providerID for Stat calls Signed-off-by: jkoberg --- internal/grpc/services/storageprovider/storageprovider.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 10c8d5ba03..4b7b11dd32 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -695,8 +695,9 @@ func (s *service) Move(ctx context.Context, req *provider.MoveRequest) (*provide } func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) { + var providerID string if req.Ref.GetResourceId() != nil { - req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + req.Ref.ResourceId.StorageId, providerID = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) } ctx, span := rtrace.Provider.Tracer("reva").Start(ctx, "stat") @@ -714,7 +715,7 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide }, nil } - md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), s.conf.MountID) + md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), providerID) return &provider.StatResponse{ Status: status.NewOK(ctx), Info: md, From 53dbba978e97399f1bc45b16062ce9098b9e8f4c Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 18:50:14 +0200 Subject: [PATCH 04/18] storageid unwrap for sharesstorageprovider Signed-off-by: jkoberg --- .../sharesstorageprovider.go | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 87395a6a24..18323a344c 100644 --- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -26,6 +26,7 @@ import ( "strings" "github.com/cs3org/reva/v2/pkg/share" + "github.com/cs3org/reva/v2/pkg/utils/resourceid" "google.golang.org/grpc" codes "google.golang.org/grpc/codes" gstatus "google.golang.org/grpc/status" @@ -105,6 +106,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -129,6 +134,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -153,6 +162,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -205,6 +218,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -289,6 +306,14 @@ 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, _ := resourceid.StorageIDUnwrap(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 @@ -473,6 +498,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -496,6 +525,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -533,6 +566,12 @@ 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, _ = resourceid.StorageIDUnwrap(req.Source.ResourceId.StorageId) + } + if req.Destination.GetResourceId() != nil { + req.Destination.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Destination.ResourceId.StorageId) + } appctx.GetLogger(ctx).Debug(). Interface("source", req.Source). @@ -631,6 +670,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + if isVirtualRoot(req.Ref.ResourceId) && (req.Ref.Path == "" || req.Ref.Path == ".") { receivedShares, shareMd, err := s.fetchShares(ctx) if err != nil { @@ -712,6 +755,10 @@ func isVirtualRoot(id *provider.ResourceId) bool { }) } func (s *service) ListContainer(ctx context.Context, req *provider.ListContainerRequest) (*provider.ListContainerResponse, error) { + if req.Ref.GetResourceId() != nil { + req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + if isVirtualRoot(req.Ref.ResourceId) { // The root is empty, it is filled by mountpoints return &provider.ListContainerResponse{ @@ -744,6 +791,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -768,6 +819,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref) appctx.GetLogger(ctx).Debug(). Interface("ref", req.Ref). @@ -841,6 +896,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + // FIXME use req.Ref to get real quota return &provider.GetQuotaResponse{ Status: status.NewOK(ctx), From 0b673f564f337c1a8108dee314ea86f14de567df Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 18:54:35 +0200 Subject: [PATCH 05/18] storageid unwrap for publicstorageprovider Signed-off-by: jkoberg --- .../publicstorageprovider.go | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/internal/grpc/services/publicstorageprovider/publicstorageprovider.go b/internal/grpc/services/publicstorageprovider/publicstorageprovider.go index 8dfb62c65b..c7b1596e57 100644 --- a/internal/grpc/services/publicstorageprovider/publicstorageprovider.go +++ b/internal/grpc/services/publicstorageprovider/publicstorageprovider.go @@ -39,6 +39,7 @@ import ( "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" rtrace "github.com/cs3org/reva/v2/pkg/trace" "github.com/cs3org/reva/v2/pkg/utils" + "github.com/cs3org/reva/v2/pkg/utils/resourceid" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" "go.opentelemetry.io/otel/attribute" @@ -102,6 +103,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -120,6 +125,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -134,6 +143,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -148,6 +161,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -162,6 +179,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -175,6 +196,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + statReq := &provider.StatRequest{Ref: req.Ref} statRes, err := s.Stat(ctx, statReq) if err != nil { @@ -297,6 +322,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + cs3Ref, _, ls, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -380,6 +409,14 @@ 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, _ := resourceid.StorageIDUnwrap(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{} @@ -511,6 +548,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx, span := rtrace.Provider.Tracer("publicstorageprovider").Start(ctx, "CreateContainer") defer span.End() @@ -551,6 +592,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ref, _, _, st, err := s.translatePublicRefToCS3Ref(ctx, req.Ref) switch { case err != nil: @@ -564,6 +609,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx, span := rtrace.Provider.Tracer("publicstorageprovider").Start(ctx, "Delete") defer span.End() @@ -604,6 +653,13 @@ 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, _ = resourceid.StorageIDUnwrap(req.Source.ResourceId.StorageId) + } + if req.Destination.GetResourceId() != nil { + req.Destination.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Destination.ResourceId.StorageId) + } + ctx, span := rtrace.Provider.Tracer("publicstorageprovider").Start(ctx, "Move") defer span.End() @@ -667,6 +723,10 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } + ctx, span := rtrace.Provider.Tracer("publicstorageprovider").Start(ctx, "Stat") defer span.End() @@ -764,6 +824,9 @@ 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, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) + } share, ok := extractLinkFromScope(ctx) if !ok { From ee981ccd9a2cf628e6e20473f8253a604e1c8e17 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 27 Apr 2022 19:42:30 +0200 Subject: [PATCH 06/18] fallback to providerid if empty Signed-off-by: jkoberg --- internal/grpc/services/storageprovider/storageprovider.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 4b7b11dd32..79e843c1b8 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -715,6 +715,9 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide }, nil } + if providerID == "" { + providerID = s.conf.MountID + } md.Id.StorageId = resourceid.StorageIDWrap(md.Id.GetStorageId(), providerID) return &provider.StatResponse{ Status: status.NewOK(ctx), From dc44e02dfeb025ce479cac4ee22866b0cf602795 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 10:56:48 +0200 Subject: [PATCH 07/18] add mountid config for storage providers Signed-off-by: jkoberg --- tests/oc-integration-tests/drone/storage-publiclink.toml | 1 + tests/oc-integration-tests/drone/storage-shares.toml | 1 + tests/oc-integration-tests/drone/storage-users-ocis.toml | 1 + tests/oc-integration-tests/drone/storage-users-s3ng.toml | 1 + tests/oc-integration-tests/local/storage-publiclink.toml | 1 + tests/oc-integration-tests/local/storage-shares.toml | 3 ++- tests/oc-integration-tests/local/storage-users.toml | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/oc-integration-tests/drone/storage-publiclink.toml b/tests/oc-integration-tests/drone/storage-publiclink.toml index 4cb5fc8e54..6786bca653 100644 --- a/tests/oc-integration-tests/drone/storage-publiclink.toml +++ b/tests/oc-integration-tests/drone/storage-publiclink.toml @@ -12,4 +12,5 @@ address = "0.0.0.0:13000" # we have a locally running dataprovider [grpc.services.publicstorageprovider] gateway_addr = "0.0.0.0:19000" +mount_id = "7993447f-687f-490d-875c-ac95e89a62a4" diff --git a/tests/oc-integration-tests/drone/storage-shares.toml b/tests/oc-integration-tests/drone/storage-shares.toml index 76a5438ab3..49351fe30e 100644 --- a/tests/oc-integration-tests/drone/storage-shares.toml +++ b/tests/oc-integration-tests/drone/storage-shares.toml @@ -10,3 +10,4 @@ address = "0.0.0.0:14000" # we have a locally running dataprovider [grpc.services.sharesstorageprovider] usershareprovidersvc = "localhost:17000" +mount_id = "a0ca6a90-a365-4782-871e-d44447bbc668" diff --git a/tests/oc-integration-tests/drone/storage-users-ocis.toml b/tests/oc-integration-tests/drone/storage-users-ocis.toml index 490b431cfc..0fc1662230 100644 --- a/tests/oc-integration-tests/drone/storage-users-ocis.toml +++ b/tests/oc-integration-tests/drone/storage-users-ocis.toml @@ -18,6 +18,7 @@ driver = "ocis" expose_data_server = true data_server_url = "http://revad-services:11001/data" gateway_addr = "0.0.0.0:19000" +mount_id = "1284d238-aa92-42ce-bdc4-0b0000009157" [grpc.services.storageprovider.drivers.ocis] root = "/drone/src/tmp/reva/data" diff --git a/tests/oc-integration-tests/drone/storage-users-s3ng.toml b/tests/oc-integration-tests/drone/storage-users-s3ng.toml index 88b707ae45..e68e61deef 100644 --- a/tests/oc-integration-tests/drone/storage-users-s3ng.toml +++ b/tests/oc-integration-tests/drone/storage-users-s3ng.toml @@ -16,6 +16,7 @@ address = "0.0.0.0:11000" driver = "s3ng" expose_data_server = true data_server_url = "http://revad-services:11001/data" +mount_id = "1284d238-aa92-42ce-bdc4-0b0000009157" [grpc.services.storageprovider.drivers.s3ng] root = "/drone/src/tmp/reva/data" diff --git a/tests/oc-integration-tests/local/storage-publiclink.toml b/tests/oc-integration-tests/local/storage-publiclink.toml index 31f95afcfb..c8a4312f23 100644 --- a/tests/oc-integration-tests/local/storage-publiclink.toml +++ b/tests/oc-integration-tests/local/storage-publiclink.toml @@ -16,3 +16,4 @@ address = "0.0.0.0:13000" # we have a locally running dataprovider [grpc.services.publicstorageprovider] gateway_addr = "0.0.0.0:19000" +mount_id = "7993447f-687f-490d-875c-ac95e89a62a4" diff --git a/tests/oc-integration-tests/local/storage-shares.toml b/tests/oc-integration-tests/local/storage-shares.toml index 947c0b5740..f4cb857570 100644 --- a/tests/oc-integration-tests/local/storage-shares.toml +++ b/tests/oc-integration-tests/local/storage-shares.toml @@ -13,4 +13,5 @@ address = "0.0.0.0:14000" # This is a storage provider that grants direct access to the wrapped storage # we have a locally running dataprovider [grpc.services.sharesstorageprovider] -usershareprovidersvc = "0.0.0.0:17000" \ No newline at end of file +usershareprovidersvc = "0.0.0.0:17000" +mount_id = "a0ca6a90-a365-4782-871e-d44447bbc668" diff --git a/tests/oc-integration-tests/local/storage-users.toml b/tests/oc-integration-tests/local/storage-users.toml index a270504b28..9d08cd5465 100644 --- a/tests/oc-integration-tests/local/storage-users.toml +++ b/tests/oc-integration-tests/local/storage-users.toml @@ -21,6 +21,7 @@ address = "0.0.0.0:11000" driver = "ocis" expose_data_server = true data_server_url = "http://localhost:11001/data" +mount_id = "1284d238-aa92-42ce-bdc4-0b0000009157" [grpc.services.storageprovider.drivers.ocis] root = "/var/tmp/reva/data" From d375e2f3b8ec3917da5ba562f3a5e270b2ba68ba Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 10:59:17 +0200 Subject: [PATCH 08/18] add storageid unwrap functionality Signed-off-by: jkoberg --- .../storageprovider/storageprovider.go | 1 + pkg/utils/resourceid/owncloud.go | 53 ++++++++---- pkg/utils/resourceid/owncloud_test.go | 85 ++++++++++++++++--- 3 files changed, 111 insertions(+), 28 deletions(-) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 79e843c1b8..942c2efc8b 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -62,6 +62,7 @@ type config struct { ExposeDataServer bool `mapstructure:"expose_data_server" docs:"false;Whether to expose data server."` // if true the client will be able to upload/download directly to it AvailableXS map[string]uint32 `mapstructure:"available_checksums" docs:"nil;List of available checksums."` CustomMimeTypesJSON string `mapstructure:"custom_mimetypes_json" docs:"nil;An optional mapping file with the list of supported custom file extensions and corresponding mime types."` + MountID string `mapstructure:"mount_id"` } func (c *config) init() { diff --git a/pkg/utils/resourceid/owncloud.go b/pkg/utils/resourceid/owncloud.go index c6041f902c..d566f1c8b3 100644 --- a/pkg/utils/resourceid/owncloud.go +++ b/pkg/utils/resourceid/owncloud.go @@ -27,44 +27,63 @@ import ( ) const ( - idDelimiter string = "!" + _idDelimiter string = "!" + _providerDelimiter string = "$" ) +// StorageIDUnwrap unwraps the 'encoded' into the storageID and the storageProviderID +func StorageIDUnwrap(s string) (sid string, spid string) { + spid, sid, err := unwrap(s, _providerDelimiter) + if err != nil { + // assume it's only a storageid + return s, "" + } + return sid, spid +} + // OwnCloudResourceIDUnwrap returns the wrapped resource id // by OwnCloudResourceIDWrap and returns nil if not possible func OwnCloudResourceIDUnwrap(rid string) *provider.ResourceId { - id, err := unwrap(rid) + sid, oid, err := unwrap(rid, _idDelimiter) if err != nil { return nil } - return id + return &provider.ResourceId{ + StorageId: sid, + OpaqueId: oid, + } } -func unwrap(rid string) (*provider.ResourceId, error) { - parts := strings.SplitN(rid, idDelimiter, 2) +func unwrap(rid string, delimiter string) (string, string, error) { + parts := strings.SplitN(rid, delimiter, 2) if len(parts) != 2 { - return nil, errors.New("could not find two parts with given delimiter") + return "", "", errors.New("could not find two parts with given delimiter") } if !utf8.ValidString(parts[0]) || !utf8.ValidString(parts[1]) { - return nil, errors.New("invalid utf8 string found") + return "", "", errors.New("invalid utf8 string found") } - return &provider.ResourceId{ - StorageId: parts[0], - OpaqueId: parts[1], - }, nil + return parts[0], parts[1], nil } // OwnCloudResourceIDWrap wraps a resource id into a xml safe string // which can then be passed to the outside world func OwnCloudResourceIDWrap(r *provider.ResourceId) string { - return wrap(r.StorageId, r.OpaqueId) + return wrap(r.StorageId, r.OpaqueId, _idDelimiter) } -// The storageID and OpaqueID need to be separated by a delimiter -// this delimiter should be Url safe -// we use a reserved character -func wrap(sid string, oid string) string { - return sid + idDelimiter + oid +// StorageIDWrap wraps a storageid and storageproviderid into a xml safe string +// which can then be passed to the outside world +func StorageIDWrap(sid string, spid string) string { + return wrap(spid, sid, _providerDelimiter) +} + +// returns second argument in case the first is empty (without adding the delimiter) +// the delimiter should be Url safe (we use a reserved character) +func wrap(first string, second string, delimiter string) string { + if first == "" { + return second + } + return first + delimiter + second } diff --git a/pkg/utils/resourceid/owncloud_test.go b/pkg/utils/resourceid/owncloud_test.go index e87e4bea4f..3681547369 100644 --- a/pkg/utils/resourceid/owncloud_test.go +++ b/pkg/utils/resourceid/owncloud_test.go @@ -26,13 +26,13 @@ import ( func BenchmarkWrap(b *testing.B) { for i := 0; i < b.N; i++ { - _ = wrap("storageid", "opaqueid") + _ = wrap("storageid", "opaqueid", "!") } } func TestWrap(t *testing.T) { - expected := "storageid" + idDelimiter + "opaqueid" - wrapped := wrap("storageid", "opaqueid") + expected := "storageid!opaqueid" + wrapped := wrap("storageid", "opaqueid", "!") if wrapped != expected { t.Errorf("wrapped id doesn't have the expected format: got %s expected %s", wrapped, expected) @@ -40,7 +40,7 @@ func TestWrap(t *testing.T) { } func TestWrapResourceID(t *testing.T) { - expected := "storageid" + idDelimiter + "opaqueid" + expected := "storageid" + _idDelimiter + "opaqueid" wrapped := OwnCloudResourceIDWrap(&providerv1beta1.ResourceId{StorageId: "storageid", OpaqueId: "opaqueid"}) if wrapped != expected { @@ -48,21 +48,47 @@ func TestWrapResourceID(t *testing.T) { } } +func TestWrapStorageID(t *testing.T) { + expected := "providerid" + _providerDelimiter + "storageid" + wrapped := StorageIDWrap("storageid", "providerid") + + if wrapped != expected { + t.Errorf("wrapped id doesn't have the expected format: got %s expected %s", wrapped, expected) + } +} + +func TestUnwrap(t *testing.T) { + expected := []string{"storageid", "opaqueid"} + sid, oid, err := unwrap("storageid!opaqueid", "!") + if err != nil { + t.Errorf("unwrap returned an error: %v", err) + } + + if sid != expected[0] || oid != expected[1] { + t.Errorf("wrapped id doesn't have the expected format: got (%s, %s) expected %s", sid, oid, expected) + } +} + func BenchmarkUnwrap(b *testing.B) { + delimiter := "!" for i := 0; i < b.N; i++ { - _, _ = unwrap("storageid" + idDelimiter + "opaqueid") + _, _, _ = unwrap("storageid"+delimiter+"opaqueid", delimiter) } } -func TestUnwrap(t *testing.T) { +func TestUnwrapResourceID(t *testing.T) { tests := []struct { input string expected *providerv1beta1.ResourceId }{ { - "storageid" + idDelimiter + "opaqueid", + "storageid" + _idDelimiter + "opaqueid", &providerv1beta1.ResourceId{StorageId: "storageid", OpaqueId: "opaqueid"}, }, + { + "providerid" + _providerDelimiter + "storageid" + _idDelimiter + "opaqueid", + &providerv1beta1.ResourceId{StorageId: "providerid$storageid", OpaqueId: "opaqueid"}, + }, { "", nil, @@ -75,13 +101,50 @@ func TestUnwrap(t *testing.T) { for _, tt := range tests { rid := OwnCloudResourceIDUnwrap(tt.input) - - if tt.expected == nil { + switch { + case tt.expected == nil: if rid != nil { t.Errorf("Expected unwrap to return nil, got %v", rid) } - } else if !utils.ResourceIDEqual(rid, tt.expected) { - t.Error("StorageID or OpaqueID doesn't match") + case !utils.ResourceIDEqual(rid, tt.expected): + t.Errorf("StorageID or OpaqueID doesn't match. Expected %v, got %v", tt.expected, rid) + } + } + +} + +func TestUnwrapStorageID(t *testing.T) { + tests := []struct { + input string + expected []string + }{ + { + "providerid" + _providerDelimiter + "storageid", + []string{"storageid", "providerid"}, + }, + { + "", + nil, + }, + { + "storageid", + []string{"storageid", ""}, + }, + } + + for _, tt := range tests { + sid, spid := StorageIDUnwrap(tt.input) + switch { + case tt.expected == nil: + if sid != "" || spid != "" { + t.Errorf("Expected unwrap to return nil, got '%s' '%s'", sid, spid) + } + case len(tt.expected) != 2: + t.Error("testcase won't work with len(expected) != 2. Avoiding panic") + case sid != tt.expected[0]: + t.Errorf("StorageID doesn't match, expected '%s' got '%s'", tt.expected[0], sid) + case spid != tt.expected[1]: + t.Errorf("ProviderID doesn't match, expected '%s' got '%s'", tt.expected[1], spid) } } From fffba1a16dae2b8284ed226f02dfea2e4d956a83 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 11:05:25 +0200 Subject: [PATCH 09/18] changelog Signed-off-by: jkoberg --- changelog/unreleased/fake-providerids.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/fake-providerids.md diff --git a/changelog/unreleased/fake-providerids.md b/changelog/unreleased/fake-providerids.md new file mode 100644 index 0000000000..f26c399d86 --- /dev/null +++ b/changelog/unreleased/fake-providerids.md @@ -0,0 +1,6 @@ +Enhancement: fake providerids so API stays stable after beta + +To support the stativ registry, we need to accept providerids +This fakes the ids so the API can stay stable + +https://github.com/cs3org/reva/pull/2790 From 895685f42baed27a8b34b725e8984ef5601e4795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 28 Apr 2022 10:49:15 +0000 Subject: [PATCH 10/18] fix listing trash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- internal/grpc/services/storageprovider/storageprovider.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 942c2efc8b..5a47ea9b72 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -903,7 +903,9 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ } for _, i := range items { - i.Ref.ResourceId.StorageId = resourceid.StorageIDWrap(i.Ref.GetResourceId().GetStorageId(), s.conf.MountID) + if i.Ref != nil && i.Ref.ResourceId != nil { + i.Ref.ResourceId.StorageId = resourceid.StorageIDWrap(i.Ref.GetResourceId().GetStorageId(), s.conf.MountID) + } } res := &provider.ListRecycleResponse{ Status: status.NewOK(ctx), From acd7803cbb42bf81c8a23a7597db29e92ec65c94 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 13:05:12 +0200 Subject: [PATCH 11/18] cut providerid from opaqueid Signed-off-by: jkoberg --- pkg/utils/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 4e31bd9c17..1a8266ed99 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -38,6 +38,7 @@ import ( types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/v2/pkg/registry" "github.com/cs3org/reva/v2/pkg/registry/memory" + "github.com/cs3org/reva/v2/pkg/utils/resourceid" "github.com/golang/protobuf/proto" "google.golang.org/protobuf/encoding/protojson" ) @@ -334,7 +335,8 @@ func SplitStorageSpaceID(ssid string) (storageid, nodeid string, err error) { } parts := strings.SplitN(ssid, spaceIDDelimiter, 2) if len(parts) == 1 { - return parts[0], parts[0], nil + p, _ := resourceid.StorageIDUnwrap(parts[0]) + return parts[0], p, nil } return parts[0], parts[1], nil } From 2110b7fdbf92bcb829fcb828f7eec094822d2bd0 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 13:29:39 +0200 Subject: [PATCH 12/18] fix import cycle in resourceid unit tests Signed-off-by: jkoberg --- pkg/utils/resourceid/owncloud_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/utils/resourceid/owncloud_test.go b/pkg/utils/resourceid/owncloud_test.go index 3681547369..775ccd314c 100644 --- a/pkg/utils/resourceid/owncloud_test.go +++ b/pkg/utils/resourceid/owncloud_test.go @@ -21,7 +21,6 @@ import ( "testing" providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" - "github.com/cs3org/reva/v2/pkg/utils" ) func BenchmarkWrap(b *testing.B) { @@ -106,8 +105,12 @@ func TestUnwrapResourceID(t *testing.T) { if rid != nil { t.Errorf("Expected unwrap to return nil, got %v", rid) } - case !utils.ResourceIDEqual(rid, tt.expected): - t.Errorf("StorageID or OpaqueID doesn't match. Expected %v, got %v", tt.expected, rid) + case rid == nil: + t.Errorf("ResourceID should not be nil. Expected %v", tt.expected) + case rid.StorageId != tt.expected.StorageId: + t.Errorf("StorageIDs don't match. Expected %v, got %v", tt.expected, rid) + case rid.OpaqueId != tt.expected.OpaqueId: + t.Errorf("StorageIDs don't match. Expected %v, got %v", tt.expected, rid) } } From badd7ed293b52b747373b4c01ee940d897fbbcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 28 Apr 2022 11:58:47 +0000 Subject: [PATCH 13/18] fix restore recycle item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- internal/grpc/services/storageprovider/storageprovider.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 5a47ea9b72..8ab295ee48 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -918,6 +918,9 @@ func (s *service) RestoreRecycleItem(ctx context.Context, req *provider.RestoreR if req.Ref.GetResourceId() != nil { req.Ref.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.Ref.ResourceId.StorageId) } + if req.RestoreRef.GetResourceId() != nil { + req.RestoreRef.ResourceId.StorageId, _ = resourceid.StorageIDUnwrap(req.RestoreRef.ResourceId.StorageId) + } ctx = ctxpkg.ContextSetLockID(ctx, req.LockId) From 764917cc7af10c5b085c73dd1b2e317cfcaab8b9 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 15:00:54 +0200 Subject: [PATCH 14/18] use feature core Signed-off-by: jkoberg --- .drone.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.env b/.drone.env index eeee12919e..a5fe15dc51 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The test runner source for API tests -CORE_COMMITID=b262ada63569e241f9cee451c23f267512fd48b2 -CORE_BRANCH=master +CORE_COMMITID=45bf01b0dbd86bd593dfb43f86b287e4aa040a5b +CORE_BRANCH=ExcapeDollarForHref From 19b6d7769b22423d4e025e30f3d2b64dcb18a6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 28 Apr 2022 13:57:10 +0000 Subject: [PATCH 15/18] add missing share_with_user_type in share data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../services/owncloud/ocs/conversions/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/http/services/owncloud/ocs/conversions/main.go b/internal/http/services/owncloud/ocs/conversions/main.go index 9abf695cec..a7a252c261 100644 --- a/internal/http/services/owncloud/ocs/conversions/main.go +++ b/internal/http/services/owncloud/ocs/conversions/main.go @@ -54,6 +54,12 @@ const ( // ShareTypeSpaceMembership represents an action regarding space members ShareTypeSpaceMembership ShareType = 7 + + // ShareWithUserTypeUser represents a normal user + ShareWithUserTypeUser ShareWithUserType = 0 + + // ShareWithUserTypeGuest represents a guest user + ShareWithUserTypeGuest ShareWithUserType = 1 ) // ResourceType indicates the OCS type of the resource @@ -78,6 +84,9 @@ func (rt ResourceType) String() (s string) { // ShareType denotes a type of share type ShareType int +// ShareWithUserType denotes a type of user +type ShareWithUserType int + // ShareData represents https://doc.owncloud.com/server/developer_manual/core/ocs-share-api.html#response-attributes-1 type ShareData struct { // TODO int? @@ -130,6 +139,10 @@ type ShareData struct { // - a UID (user id) if the share is shared with a user. // - a password for public links ShareWith string `json:"share_with,omitempty" xml:"share_with,omitempty"` + // The type of user + // - 0 = normal user + // - 1 = guest account + ShareWithUserType ShareWithUserType `json:"share_with_user_type" xml:"share_with_user_type"` // The display name of the share recipient ShareWithDisplayname string `json:"share_with_displayname,omitempty" xml:"share_with_displayname,omitempty"` // Additional info to identify the share recipient, eg. the email or username @@ -206,6 +219,11 @@ func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*Share if share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { sd.ShareType = ShareTypeUser sd.ShareWith = LocalUserIDToString(share.Grantee.GetUserId()) + if share.GetGrantee().GetUserId().Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT { + sd.ShareWithUserType = ShareWithUserTypeGuest + } else { + sd.ShareWithUserType = ShareWithUserTypeUser + } } else if share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_GROUP { sd.ShareType = ShareTypeGroup sd.ShareWith = LocalGroupIDToString(share.Grantee.GetGroupId()) From 6692a3af88c7a84bc0ced88a781c42ebaa9ed02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 28 Apr 2022 14:05:56 +0000 Subject: [PATCH 16/18] prevent panic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- internal/http/services/owncloud/ocs/conversions/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocs/conversions/main.go b/internal/http/services/owncloud/ocs/conversions/main.go index a7a252c261..ef087fdf53 100644 --- a/internal/http/services/owncloud/ocs/conversions/main.go +++ b/internal/http/services/owncloud/ocs/conversions/main.go @@ -219,7 +219,7 @@ func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*Share if share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { sd.ShareType = ShareTypeUser sd.ShareWith = LocalUserIDToString(share.Grantee.GetUserId()) - if share.GetGrantee().GetUserId().Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT { + if share.GetGrantee().GetUserId().GetType() == userpb.UserType_USER_TYPE_LIGHTWEIGHT { sd.ShareWithUserType = ShareWithUserTypeGuest } else { sd.ShareWithUserType = ShareWithUserTypeUser From d2e4852ee48319974024346827e96edc8c988011 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 16:07:09 +0200 Subject: [PATCH 17/18] bump core commit id Signed-off-by: jkoberg --- .drone.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.env b/.drone.env index a5fe15dc51..46fa7131e6 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The test runner source for API tests -CORE_COMMITID=45bf01b0dbd86bd593dfb43f86b287e4aa040a5b +CORE_COMMITID=00386f095889bdb96056420c5eb32e902d61faed CORE_BRANCH=ExcapeDollarForHref From 6bc3f58f8e68fec0d12d5f8750b9988ae699c6bf Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 28 Apr 2022 16:33:08 +0200 Subject: [PATCH 18/18] use feature core Signed-off-by: jkoberg --- .drone.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.env b/.drone.env index 46fa7131e6..f8dfbf4ad6 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The test runner source for API tests -CORE_COMMITID=00386f095889bdb96056420c5eb32e902d61faed -CORE_BRANCH=ExcapeDollarForHref +CORE_COMMITID=69d8f1e0027d5763ef7d011aaff2df33beff16d +CORE_BRANCH=EscapeDollarOcisEdition