Skip to content

Commit

Permalink
handle space does not exist (#2422)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic authored Jan 7, 2022
1 parent 8fbeeab commit c05e074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: handle non existing spaces correctly

When looking up a space by id we returned the wrong status code.

https://github.com/cs3org/reva/pull/2422
11 changes: 7 additions & 4 deletions internal/http/services/owncloud/ocdav/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,18 @@ func (s *svc) lookUpStorageSpaceByID(ctx context.Context, spaceID string) (*stor
return nil, lSSRes.Status, err
}

if len(lSSRes.StorageSpaces) != 1 {
switch len(lSSRes.StorageSpaces) {
case 0:
return nil, &rpc.Status{Code: rpc.Code_CODE_NOT_FOUND}, nil // since the caller only expects a single space return not found status
case 1:
return lSSRes.StorageSpaces[0], lSSRes.Status, nil
default:
return nil, nil, fmt.Errorf("unexpected number of spaces %d", len(lSSRes.StorageSpaces))
}
return lSSRes.StorageSpaces[0], lSSRes.Status, nil

}
func (s *svc) lookUpStorageSpaceReference(ctx context.Context, spaceID string, relativePath string, spacesDavRequest bool) (*storageProvider.Reference, *rpc.Status, error) {
space, status, err := s.lookUpStorageSpaceByID(ctx, spaceID)
if err != nil {
if space == nil {
return nil, status, err
}
return makeRelativeReference(space, relativePath, spacesDavRequest), status, err
Expand Down

0 comments on commit c05e074

Please sign in to comment.