From 6d077ec082175763ecd69be82a97211ed1ef8853 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Mon, 27 Nov 2023 15:19:16 +0100 Subject: [PATCH] fix: public link creation err return if not ok --- .../fix-public-link-creation-err.md | 5 +++++ .../publicshareprovider.go | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 changelog/unreleased/fix-public-link-creation-err.md diff --git a/changelog/unreleased/fix-public-link-creation-err.md b/changelog/unreleased/fix-public-link-creation-err.md new file mode 100644 index 0000000000..649f42d428 --- /dev/null +++ b/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 diff --git a/internal/grpc/services/publicshareprovider/publicshareprovider.go b/internal/grpc/services/publicshareprovider/publicshareprovider.go index f142d76fa0..33b7bcd3dc 100644 --- a/internal/grpc/services/publicshareprovider/publicshareprovider.go +++ b/internal/grpc/services/publicshareprovider/publicshareprovider.go @@ -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" @@ -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() { @@ -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 }