Skip to content

Commit

Permalink
Merge pull request #4635 from 2403905/issue-8768
Browse files Browse the repository at this point in the history
fix nil pointer when removing groups from space
  • Loading branch information
2403905 committed Apr 17, 2024
2 parents 56d2be7 + 1b9fc92 commit f30ce62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
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
}

0 comments on commit f30ce62

Please sign in to comment.