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 space share update for ocs #4661

Merged
merged 1 commit into from
Apr 26, 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-spase-share-update-ocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix space share update for ocs

We fixed the space share update for ocs.

https://github.com/cs3org/reva/pull/4661
https://github.com/owncloud/ocis/issues/8905
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/pkg/errors"
"google.golang.org/protobuf/types/known/fieldmaskpb"
)

func (h *Handler) getGrantee(ctx context.Context, name string) (provider.Grantee, error) {
Expand Down Expand Up @@ -108,8 +109,10 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
// The viewer role doesn't have the ListGrants permission so we set it here.
permissions.ListGrants = true

fieldmask := []string{}
expireDate := r.PostFormValue("expireDate")
var expirationTs *types.Timestamp
fieldmask = append(fieldmask, "expiration")
if expireDate != "" {
expiration, err := time.Parse(_iso8601, expireDate)
if err != nil {
Expand All @@ -125,6 +128,7 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
Seconds: uint64(expiration.UnixNano() / int64(time.Second)),
Nanos: uint32(expiration.UnixNano() % int64(time.Second)),
}
fieldmask = append(fieldmask, "expiration")
}

ref := provider.Reference{ResourceId: info.GetId()}
Expand Down Expand Up @@ -154,6 +158,9 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
// we have to send the update request to the gateway to give it a chance to invalidate its cache
// TODO the gateway no longer should cache stuff because invalidation is to expensive. The decomposedfs already has a better cache.
if granteeExists(lgRes.Grants, grantee) {
if permissions != nil {
fieldmask = append(fieldmask, "permissions")
}
updateShareReq := &collaborationv1beta1.UpdateShareRequest{
// TODO: change CS3 APIs
Opaque: &types.Opaque{
Expand All @@ -169,6 +176,9 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
Grantee: &grantee,
Expiration: expirationTs,
},
UpdateMask: &fieldmaskpb.FieldMask{
Paths: fieldmask,
},
}
updateShareReq.Opaque = utils.AppendPlainToOpaque(updateShareReq.Opaque, "spacetype", info.GetSpace().GetSpaceType())
updateShareRes, err := client.UpdateShare(ctx, updateShareReq)
Expand Down
Loading