Skip to content

Commit

Permalink
fix: public link creation err return if not ok
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade committed Nov 27, 2023
1 parent ff25cbb commit 6d077ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-public-link-creation-err.md
@@ -0,0 +1,5 @@
Bugfix: Fix create public share

If public link creation failed, it now returns a status error instead of sending ok.

https://github.com/cs3org/reva/pull/4365
21 changes: 12 additions & 9 deletions internal/grpc/services/publicshareprovider/publicshareprovider.go
Expand Up @@ -24,6 +24,10 @@ import (

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"google.golang.org/grpc"

"github.com/cs3org/reva/v2/pkg/appctx"
"github.com/cs3org/reva/v2/pkg/conversions"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
Expand All @@ -32,9 +36,6 @@ import (
"github.com/cs3org/reva/v2/pkg/publicshare/manager/registry"
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"google.golang.org/grpc"
)

func init() {
Expand Down Expand Up @@ -163,15 +164,17 @@ func (s *service) CreatePublicShare(ctx context.Context, req *link.CreatePublicS
log.Error().Msg("error getting user from context")
}

res := &link.CreatePublicShareResponse{}
share, err := s.sm.CreatePublicShare(ctx, u, req.ResourceInfo, req.Grant)
if err != nil {
log.Debug().Err(err).Str("createShare", "shares").Msg("error connecting to storage provider")
switch {
case err != nil:
log.Error().Err(err).Interface("request", req).Msg("could not write public share")
res.Status = status.NewInternal(ctx, "error persisting public share:"+err.Error())
default:
res.Status = status.NewOK(ctx)
res.Share = share
}

res := &link.CreatePublicShareResponse{
Status: status.NewOK(ctx),
Share: share,
}
return res, nil
}

Expand Down

0 comments on commit 6d077ec

Please sign in to comment.