Skip to content

Commit

Permalink
add missing error check in decomposedfs (#3430)
Browse files Browse the repository at this point in the history
* add missing error check in decomposedfs

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* disable codacy

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Nov 3, 2022
1 parent 65012c8 commit dda4d03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/decomposedfs-check-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: add missing error check in decomposedfs

During space creation the decomposedfs now checks for errors when trying to read the root node. This prevents a panic by no longer calling InternalPath on the node.

https://github.com/cs3org/reva/pull/3430
https://github.com/owncloud/ocis/issues/4961
9 changes: 5 additions & 4 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
}

root, err := node.ReadNode(ctx, fs.lu, spaceID, spaceID, true) // will fall into `Exists` case below
if err == nil && root.Exists {
switch {
case err != nil:
return nil, err
case root.Exists:
return nil, errtypes.AlreadyExists("decomposedfs: spaces: space already exists")
}

if !fs.canCreateSpace(ctx, spaceID) {
case !fs.canCreateSpace(ctx, spaceID):
return nil, errtypes.PermissionDenied(spaceID)
}

Expand Down

0 comments on commit dda4d03

Please sign in to comment.