Skip to content

Commit 8c0cdd1

Browse files
committed
fix: remove grant from storage when removing OCM share
Fixes: owncloud/ocis#10262
1 parent 3e75a1b commit 8c0cdd1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Bugfix: Deleting OCM share also updates storageprovider
2+
3+
When remvoving an OCM share we're now also removing the related grant from
4+
the storage provider.
5+
6+
https://github.com/cs3org/reva/pull/4989
7+
https://github.com/owncloud/ocis/issues/10262

internal/grpc/services/gateway/ocmshareprovider.go

+26
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,37 @@ func (s *svc) RemoveOCMShare(ctx context.Context, req *ocm.RemoveOCMShareRequest
8585
}, nil
8686
}
8787

88+
getShareRes, err := c.GetOCMShare(ctx, &ocm.GetOCMShareRequest{
89+
Ref: req.Ref,
90+
})
91+
if err != nil {
92+
return nil, errors.Wrap(err, "gateway: error calling GetOCMShare")
93+
}
94+
if getShareRes.Status.Code != rpc.Code_CODE_OK {
95+
res := &ocm.RemoveOCMShareResponse{
96+
Status: status.NewInternal(ctx,
97+
"error getting ocm share when committing to the storage"),
98+
}
99+
return res, nil
100+
}
101+
share := getShareRes.Share
102+
88103
res, err := c.RemoveOCMShare(ctx, req)
89104
if err != nil {
90105
return nil, errors.Wrap(err, "gateway: error calling RemoveOCMShare")
91106
}
92107

108+
// remove the grant from the storage provider
109+
status, err := s.removeGrant(ctx, share.GetResourceId(), share.GetGrantee(), share.GetAccessMethods()[0].GetWebdavOptions().GetPermissions(), nil)
110+
if err != nil {
111+
return nil, errors.Wrap(err, "gateway: error removing grant from storage")
112+
}
113+
if status.Code != rpc.Code_CODE_OK {
114+
return &ocm.RemoveOCMShareResponse{
115+
Status: status,
116+
}, err
117+
}
118+
93119
return res, nil
94120
}
95121

0 commit comments

Comments
 (0)