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

Return OK when trying to delete a non existing reference #2154

Merged
merged 1 commit into from
Oct 12, 2021
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
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