Skip to content

Commit

Permalink
The DeleteStorageSpace method response code has been changed to 'not …
Browse files Browse the repository at this point in the history
…found' if no one spaces in a list or errtypes.IsNotFound
  • Loading branch information
2403905 committed May 8, 2023
1 parent 756a843 commit 686b8ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 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

he DeleteStorageSpace method response code has been changed

https://github.com/cs3org/reva/pull/3848
10 changes: 8 additions & 2 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, "not found when deleting space")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
case errtypes.BadRequest:
st = status.NewInvalid(ctx, err.Error())
Expand All @@ -609,6 +611,10 @@ 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, "not found when deleting space"),
}, nil
}

if err := s.storage.DeleteStorageSpace(ctx, req); err != nil {
Expand Down

0 comments on commit 686b8ec

Please sign in to comment.