Skip to content

Commit

Permalink
handle non existent spaces gracefully (#2354)
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar authored Dec 12, 2021
1 parent d54df2f commit 778de37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/update-handle-empty-spaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Return not found when updating non existent space

If a spaceid of a space which is updated doesn't exist, handle it as a not found error.

https://github.com/cs3org/reva/pull/2354
13 changes: 12 additions & 1 deletion pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up
}

if len(matches) != 1 {
return nil, fmt.Errorf("update space failed: found %d matching spaces", len(matches))
return &provider.UpdateStorageSpaceResponse{
Status: &v1beta11.Status{
Code: v1beta11.Code_CODE_NOT_FOUND,
Message: fmt.Sprintf("update space failed: found %d matching spaces", len(matches)),
},
}, nil
}

target, err := os.Readlink(matches[0])
Expand All @@ -267,6 +272,12 @@ func (fs *Decomposedfs) UpdateStorageSpace(ctx context.Context, req *provider.Up
return nil, err
}

u, ok := ctxpkg.ContextGetUser(ctx)
if !ok {
return nil, fmt.Errorf("decomposedfs: spaces: contextual user not found")
}
space.Owner = u

if space.Name != "" {
if err := node.SetMetadata(xattrs.SpaceNameAttr, space.Name); err != nil {
return nil, err
Expand Down

0 comments on commit 778de37

Please sign in to comment.