Skip to content

Commit

Permalink
Merge pull request cs3org#4805 from aduffeck/fix-creating-spaces
Browse files Browse the repository at this point in the history
Return proper error when trying to read attrs from a non-existing node
  • Loading branch information
aduffeck authored Aug 13, 2024
2 parents 901360c + 77f0d9b commit dce7872
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-creating-spaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix creating spaces

We fixed a problem where it wasn't possible to create new spaces when running on a non-writable working directory.

https://github.com/cs3org/reva/pull/4805
14 changes: 11 additions & 3 deletions pkg/storage/utils/decomposedfs/node/xattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package node
import (
"context"
"io"
"io/fs"
"strconv"
"time"

Expand Down Expand Up @@ -144,14 +145,21 @@ func (n *Node) Xattrs(ctx context.Context) (Attributes, error) {
// Xattr returns an extended attribute of the node. If the attributes have already
// been cached it is not read from disk again.
func (n *Node) Xattr(ctx context.Context, key string) ([]byte, error) {
path := n.InternalPath()

if path == "" {
// Do not try to read the attribute of an non-existing node
return []byte{}, fs.ErrNotExist
}

if n.ID == "" {
// Do not try to read the attribute of an empty node. The InternalPath points to the
// base nodes directory in this case.
return []byte{}, &xattr.Error{Op: "node.Xattr", Path: n.InternalPath(), Name: key, Err: xattr.ENOATTR}
return []byte{}, &xattr.Error{Op: "node.Xattr", Path: path, Name: key, Err: xattr.ENOATTR}
}

if n.xattrsCache == nil {
attrs, err := n.lu.MetadataBackend().All(ctx, n.InternalPath())
attrs, err := n.lu.MetadataBackend().All(ctx, path)
if err != nil {
return []byte{}, err
}
Expand All @@ -162,7 +170,7 @@ func (n *Node) Xattr(ctx context.Context, key string) ([]byte, error) {
return val, nil
}
// wrap the error as xattr does
return []byte{}, &xattr.Error{Op: "node.Xattr", Path: n.InternalPath(), Name: key, Err: xattr.ENOATTR}
return []byte{}, &xattr.Error{Op: "node.Xattr", Path: path, Name: key, Err: xattr.ENOATTR}
}

// XattrString returns the string representation of an attribute
Expand Down

0 comments on commit dce7872

Please sign in to comment.