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

handle space does not exist #2422

Merged
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
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