Skip to content

Commit

Permalink
Merge pull request #3856 from 2403905/delete-storage-space
Browse files Browse the repository at this point in the history
The DeleteStorageSpace method response code has been changed
  • Loading branch information
micbar authored May 8, 2023
2 parents d8682ab + 04cc67c commit beefb02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit beefb02

Please sign in to comment.