Skip to content

Commit

Permalink
Merge pull request #4661 from 2403905/issues-8905-ocs
Browse files Browse the repository at this point in the history
fix space share update for ocs
  • Loading branch information
2403905 authored Apr 26, 2024
2 parents 4bb1bbd + 7197a31 commit 7ed0671
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 7ed0671

Please sign in to comment.