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

Fix/parent without stat #3975

Merged
merged 2 commits into from
Jun 15, 2023
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
3 changes: 3 additions & 0 deletions changelog/unreleased/parent-without-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: decomposedfs now resolves the parent without an os.Stat

https://github.com/cs3org/reva/pull/3975
24 changes: 13 additions & 11 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,29 +406,31 @@ func (n *Node) Child(ctx context.Context, name string) (*Node, error) {
}

// ParentWithReader returns the parent node
func (n *Node) ParentWithReader(r io.Reader) (p *Node, err error) {
func (n *Node) ParentWithReader(r io.Reader) (*Node, error) {
if n.ParentID == "" {
return nil, fmt.Errorf("decomposedfs: root has no parent")
}
p = &Node{
p := &Node{
SpaceID: n.SpaceID,
lu: n.lu,
ID: n.ParentID,
SpaceRoot: n.SpaceRoot,
}

// fill metadata cache using the reader
_, _ = p.XattrsWithReader(r)
attrs, err := p.XattrsWithReader(r)
switch {
case metadata.IsNotExist(err):
return p, nil // swallow not found, the node defaults to exists = false
case err != nil:
return nil, err
}
p.Exists = true

// lookup name and parent id in extended attributes
p.ParentID, _ = p.XattrString(prefixes.ParentidAttr)
p.Name, _ = p.XattrString(prefixes.NameAttr)
p.Name = attrs.String(prefixes.NameAttr)
p.ParentID = attrs.String(prefixes.ParentidAttr)

// check node exists
if _, err := os.Stat(p.InternalPath()); err == nil {
p.Exists = true
}
return
return p, err
}

// Parent returns the parent node
Expand Down