From a1be3c006e30e3d1ba1fd98b6a12e4307b30b4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Oct 2021 15:07:00 +0000 Subject: [PATCH] Return OK when trying to delete a non existing reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-declining-unaccepted-share.md | 6 ++++++ internal/grpc/services/gateway/usershareprovider.go | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-declining-unaccepted-share.md diff --git a/changelog/unreleased/fix-declining-unaccepted-share.md b/changelog/unreleased/fix-declining-unaccepted-share.md new file mode 100644 index 0000000000..efdfd1ec82 --- /dev/null +++ b/changelog/unreleased/fix-declining-unaccepted-share.md @@ -0,0 +1,6 @@ +Bugfix: Return OK when trying to delete a non existing reference + +When the gateway declines a share we can ignore a non existing reference. + +https://github.com/cs3org/reva/pull/2154 +https://github.com/owncloud/ocis/pull/2603 diff --git a/internal/grpc/services/gateway/usershareprovider.go b/internal/grpc/services/gateway/usershareprovider.go index 7243b4bae4..7511e0a581 100644 --- a/internal/grpc/services/gateway/usershareprovider.go +++ b/internal/grpc/services/gateway/usershareprovider.go @@ -382,6 +382,7 @@ func (s *svc) removeReference(ctx context.Context, resourceID *provider.Resource return status.NewInternal(ctx, err, "gateway: error calling Stat for the share resource id: "+resourceID.String()) } + // FIXME how can we delete a reference if the original resource was deleted? if statRes.Status.Code != rpc.Code_CODE_OK { err := status.NewErrorFromCode(statRes.Status.GetCode(), "gateway") return status.NewInternal(ctx, err, "could not delete share reference") @@ -419,7 +420,13 @@ func (s *svc) removeReference(ctx context.Context, resourceID *provider.Resource return status.NewInternal(ctx, err, "could not delete share reference") } - if deleteResp.Status.Code != rpc.Code_CODE_OK { + switch deleteResp.Status.Code { + case rpc.Code_CODE_OK: + // we can continue deleting the reference + case rpc.Code_CODE_NOT_FOUND: + // This is fine, we wanted to delete it anyway + return status.NewOK(ctx) + default: err := status.NewErrorFromCode(deleteResp.Status.GetCode(), "gateway") return status.NewInternal(ctx, err, "could not delete share reference") }