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

The DeleteStorageSpace method response code has been changed #3856

Merged
merged 1 commit into from
May 8, 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-response-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix response code

The DeleteStorageSpace method response code has been changed

https://github.com/cs3org/reva/pull/3856
12 changes: 9 additions & 3 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,12 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
id := &provider.StorageSpaceId{OpaqueId: storagespace.FormatResourceID(idraw)}

spaces, err := s.storage.ListStorageSpaces(ctx, []*provider.ListStorageSpacesRequest_Filter{{Type: provider.ListStorageSpacesRequest_Filter_TYPE_ID, Term: &provider.ListStorageSpacesRequest_Filter_Id{Id: id}}}, true)
if err != nil || len(spaces) != 1 {
if err != nil {
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound, errtypes.PermissionDenied:
case errtypes.IsNotFound:
st = status.NewNotFound(ctx, "space not found")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
case errtypes.BadRequest:
st = status.NewInvalid(ctx, err.Error())
Expand All @@ -609,13 +611,17 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
return &provider.DeleteStorageSpaceResponse{
Status: st,
}, nil
} else if len(spaces) != 1 {
return &provider.DeleteStorageSpaceResponse{
Status: status.NewNotFound(ctx, "space not found"),
}, nil
}

if err := s.storage.DeleteStorageSpace(ctx, req); err != nil {
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound:
st = status.NewNotFound(ctx, "not found when deleting space")
st = status.NewNotFound(ctx, "space not found")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
case errtypes.BadRequest:
Expand Down