diff --git a/changelog/unreleased/update-handle-empty-spaces.md b/changelog/unreleased/update-handle-empty-spaces.md new file mode 100644 index 0000000000..6ee2ebe634 --- /dev/null +++ b/changelog/unreleased/update-handle-empty-spaces.md @@ -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 diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go index 8c61ecf1e1..b34bb57f65 100644 --- a/pkg/storage/utils/decomposedfs/spaces.go +++ b/pkg/storage/utils/decomposedfs/spaces.go @@ -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]) @@ -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