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

update grants in the storage provider on share update #1258

Merged
merged 3 commits into from
Oct 20, 2020

Conversation

C0rby
Copy link
Contributor

@C0rby C0rby commented Oct 20, 2020

The grants set by the ocis storage were not updated when updating a share.
This PR reimplements the code, that was there before but commented out, in a way that is similar to the addGrant logic in CreateShare

@C0rby C0rby requested a review from labkode as a code owner October 20, 2020 12:53
@C0rby C0rby requested a review from butonic October 20, 2020 12:54
Signed-off-by: David Christofas <dchristofas@owncloud.com>
@C0rby C0rby force-pushed the update-grants-on-share-update branch from 52bd784 to 40db8d2 Compare October 20, 2020 12:54
@lgtm-com
Copy link

lgtm-com bot commented Oct 20, 2020

This pull request introduces 1 alert when merging 40db8d2 into e221f0b - view on LGTM.com

new alerts:

  • 1 for Missing error check

butonic
butonic previously approved these changes Oct 20, 2020
Comment on lines 188 to 213
// TODO(labkode): if both commits are enabled they could be done concurrently.
/*
if s.c.CommitShareToStorageGrant {
getShareReq := &collaboration.GetShareRequest{
Ref: req.Ref,
}
getShareRes, err := c.GetShare(ctx, getShareReq)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetShare")
}

if getShareRes.Status.Code != rpc.Code_CODE_OK {
return &collaboration.UpdateShareResponse{
Status: status.NewInternal(ctx, status.NewErrorFromCode(getShareRes.Status.Code, "gateway"),
"error getting share when committing to the share"),
}, nil
}
if s.c.CommitShareToStorageGrant {
getShareReq := &collaboration.GetShareRequest{
Ref: req.Ref,
}
getShareRes, err := c.GetShare(ctx, getShareReq)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetShare")
}

grantReq := &provider.UpdateGrantRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Id{
Id: getShareRes.Share.ResourceId,
},
},
Grant: &provider.Grant{
Grantee: getShareRes.Share.Grantee,
Permissions: getShareRes.Share.Permissions.Permissions,
},
}
grantRes, err := s.UpdateGrant(ctx, grantReq)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling UpdateGrant")
}
if grantRes.Status.Code != rpc.Code_CODE_OK {
return &collaboration.UpdateShareResponse{
Status: status.NewInternal(ctx, status.NewErrorFromCode(grantRes.Status.Code, "gateway"),
"error updating storage grant"),
}, nil
}
if getShareRes.Status.Code != rpc.Code_CODE_OK {
return &collaboration.UpdateShareResponse{
Status: status.NewInternal(ctx, status.NewErrorFromCode(getShareRes.Status.Code, "gateway"),
"error getting share when committing to the share"),
}, nil
}
updateGrantStatus, err := s.updateGrant(ctx, getShareRes.GetShare().GetResourceId(),
getShareRes.GetShare().GetGrantee(),
getShareRes.GetShare().GetPermissions().GetPermissions())
if updateGrantStatus.Code != rpc.Code_CODE_OK {
return &collaboration.UpdateShareResponse{
Status: updateGrantStatus,
}, err
}
*/
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@labkode any reason why this was commented?

Signed-off-by: David Christofas <dchristofas@owncloud.com>
Signed-off-by: David Christofas <dchristofas@owncloud.com>
@ishank011 ishank011 merged commit 05ab93e into cs3org:master Oct 20, 2020
@C0rby C0rby deleted the update-grants-on-share-update branch October 20, 2020 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants