Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix nil pointer when removing groups from space #4635

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-remove-group-from-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix nil pointer when removing groups from space

We fixed the nil pointer when removing groups from space via graph

https://github.com/cs3org/reva/pull/4635
https://github.com/owncloud/ocis/issues/8768
18 changes: 9 additions & 9 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ 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, spid, oid, err := storagespace.SplitID(f.GetId().OpaqueId)
sid, spid, oid, err := storagespace.SplitID(f.GetId().GetOpaqueId())
if err != nil {
continue
}
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
filters["owner_idp"] = f.GetOwner().GetIdp()
filters["owner_id"] = f.GetOwner().GetOpaqueId()
case provider.ListStorageSpacesRequest_Filter_TYPE_SPACE_TYPE:
filters["space_type"] = f.GetSpaceType()
case provider.ListStorageSpacesRequest_Filter_TYPE_USER:
Expand Down Expand Up @@ -339,7 +339,7 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
_, purge = opaque.Map["purge"]
}

rid, err := storagespace.ParseID(req.Id.OpaqueId)
rid, err := storagespace.ParseID(req.GetId().GetOpaqueId())
if err != nil {
return &provider.DeleteStorageSpaceResponse{
Status: status.NewStatusFromErrType(ctx, fmt.Sprintf("gateway could not parse space id %s", req.GetId().GetOpaqueId()), err),
Expand All @@ -361,7 +361,7 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
}, nil
}

id := &provider.ResourceId{OpaqueId: req.Id.OpaqueId}
id := &provider.ResourceId{OpaqueId: req.GetId().GetOpaqueId()}
s.providerCache.RemoveListStorageProviders(id)

if dsRes.Status.Code != rpc.Code_CODE_OK {
Expand Down Expand Up @@ -1221,11 +1221,11 @@ 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,
StorageId: ref.GetResourceId().GetStorageId(),
SpaceId: ref.GetResourceId().GetSpaceId(),
OpaqueId: ref.GetResourceId().GetOpaqueId(),
},
Path: ref.Path,
Path: ref.GetPath(),
}
}

Expand Down
14 changes: 7 additions & 7 deletions internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func (s *svc) CreateShare(ctx context.Context, req *collaboration.CreateShareReq
}

func (s *svc) RemoveShare(ctx context.Context, req *collaboration.RemoveShareRequest) (*collaboration.RemoveShareResponse, error) {
key := req.Ref.GetKey()
key := req.GetRef().GetKey()
if !s.c.UseCommonSpaceRootShareLogic && shareIsSpaceRoot(key) {
return s.removeSpaceShare(ctx, key.ResourceId, key.Grantee)
return s.removeSpaceShare(ctx, key.GetResourceId(), key.GetGrantee())
}
return s.removeShare(ctx, req)
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func (s *svc) updateShare(ctx context.Context, req *collaboration.UpdateShareReq
if updateGrantStatus.Code != rpc.Code_CODE_OK {
return &collaboration.UpdateShareResponse{
Status: updateGrantStatus,
Share: res.Share,
Share: res.GetShare(),
}, nil
}
}
Expand Down Expand Up @@ -835,11 +835,11 @@ func isEqualGrantee(a, b *provider.Grantee) bool {
var aID, bID string
switch a.Type {
case provider.GranteeType_GRANTEE_TYPE_GROUP:
aID = a.GetGroupId().OpaqueId
bID = b.GetGroupId().OpaqueId
aID = a.GetGroupId().GetOpaqueId()
bID = b.GetGroupId().GetOpaqueId()
case provider.GranteeType_GRANTEE_TYPE_USER:
aID = a.GetUserId().OpaqueId
bID = b.GetUserId().OpaqueId
aID = a.GetUserId().GetOpaqueId()
bID = b.GetUserId().GetOpaqueId()
}
return aID == bID
}
Loading