Skip to content

Commit

Permalink
Return OK when trying to delete a non existing reference
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Oct 11, 2021
1 parent 26bc95f commit a1be3c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-declining-unaccepted-share.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit a1be3c0

Please sign in to comment.