From b4ba5ff3ee36d00a87f780bd44b54e6cb8c3d315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 15 Jun 2023 09:42:46 +0200 Subject: [PATCH 1/2] drop stat and use return code from XattrsWithReader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/storage/utils/decomposedfs/node/node.go | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index ea86aaee29..f154d2db02 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -406,11 +406,11 @@ 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, @@ -418,17 +418,19 @@ func (n *Node) ParentWithReader(r io.Reader) (p *Node, err error) { } // 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 From ee3c0d71a499b28c5a18cd16e5b63e2485df7e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 15 Jun 2023 10:39:23 +0200 Subject: [PATCH 2/2] add changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/parent-without-stat.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/unreleased/parent-without-stat.md diff --git a/changelog/unreleased/parent-without-stat.md b/changelog/unreleased/parent-without-stat.md new file mode 100644 index 0000000000..1f8c9350fe --- /dev/null +++ b/changelog/unreleased/parent-without-stat.md @@ -0,0 +1,3 @@ +Bugfix: decomposedfs now resolves the parent without an os.Stat + +https://github.com/cs3org/reva/pull/3975