diff --git a/changelog/unreleased/fix-response-code.md b/changelog/unreleased/fix-response-code.md new file mode 100644 index 0000000000..2217c983f1 --- /dev/null +++ b/changelog/unreleased/fix-response-code.md @@ -0,0 +1,5 @@ +Bugfix: Fix response code + +The DeleteStorageSpace method response code has been changed + +https://github.com/cs3org/reva/pull/3856 diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index ce81eae99a..eccb45ad32 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -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()) @@ -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: