Skip to content

Commit

Permalink
fix: remove grant from storage when removing OCM share
Browse files Browse the repository at this point in the history
  • Loading branch information
rhafer committed Dec 5, 2024
1 parent 6c8fb88 commit a8a1e19
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix_ocm_removegrant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Deleting OCM share also updates storageprovider

When remvoving an OCM share we're now also removing the related grant from
the storage provider.

https://github.com/cs3org/reva/pull/4989
https://github.com/owncloud/ocis/issues/10262
26 changes: 26 additions & 0 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,37 @@ func (s *svc) RemoveOCMShare(ctx context.Context, req *ocm.RemoveOCMShareRequest
}, nil
}

getShareRes, err := c.GetOCMShare(ctx, &ocm.GetOCMShareRequest{
Ref: req.Ref,
})
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetOCMShare")
}
if getShareRes.Status.Code != rpc.Code_CODE_OK {
res := &ocm.RemoveOCMShareResponse{
Status: status.NewInternal(ctx,
"error getting ocm share when committing to the storage"),
}
return res, nil
}
share := getShareRes.Share

res, err := c.RemoveOCMShare(ctx, req)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling RemoveOCMShare")
}

// remove the grant from the storage provider
status, err := s.removeGrant(ctx, share.GetResourceId(), share.GetGrantee(), share.GetAccessMethods()[0].GetWebdavOptions().GetPermissions(), nil)
if err != nil {
return nil, errors.Wrap(err, "gateway: error removing grant from storage")
}
if status.Code != rpc.Code_CODE_OK {
return &ocm.RemoveOCMShareResponse{
Status: status,
}, err
}

return res, nil
}

Expand Down

0 comments on commit a8a1e19

Please sign in to comment.