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: public link creation err return if not ok #4365

Merged
merged 1 commit into from
Nov 27, 2023
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
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-public-link-creation-err.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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