From f3a6c3d7b55e174978e78dca3bc0339fd91d4f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 27 Nov 2020 19:32:07 +0000 Subject: [PATCH] fix ocis move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-ocis-move.md | 6 ++++++ pkg/storage/fs/ocis/tree.go | 13 +++++++------ .../expected-failures-on-OCIS-storage.txt | 2 -- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 changelog/unreleased/fix-ocis-move.md diff --git a/changelog/unreleased/fix-ocis-move.md b/changelog/unreleased/fix-ocis-move.md new file mode 100644 index 0000000000..0b48987675 --- /dev/null +++ b/changelog/unreleased/fix-ocis-move.md @@ -0,0 +1,6 @@ +Bugfix: fix ocis move + +Use the old node id to build the target path for xattr updates. + +https://github.com/cs3org/reva/pull/1343 +https://github.com/owncloud/ocis/issues/975 diff --git a/pkg/storage/fs/ocis/tree.go b/pkg/storage/fs/ocis/tree.go index 165ccf9520..0b3b0c88b2 100644 --- a/pkg/storage/fs/ocis/tree.go +++ b/pkg/storage/fs/ocis/tree.go @@ -136,6 +136,12 @@ func (t *Tree) Move(ctx context.Context, oldNode *Node, newNode *Node) (err erro return errors.Wrap(err, "ocisfs: Move: error deleting target node "+newNode.ID) } } + + // Always target the old node ID for xattr updates. + // The new node id is empty if the target does not exist + // and we need to overwrite the new one when overwriting an existing path. + tgtPath := t.lu.toInternalPath(oldNode.ID) + // are we just renaming (parent stays the same)? if oldNode.ParentID == newNode.ParentID { @@ -150,9 +156,6 @@ func (t *Tree) Move(ctx context.Context, oldNode *Node, newNode *Node) (err erro return errors.Wrap(err, "ocisfs: could not rename child") } - // the new node id might be different, so we need to use the old nodes id - tgtPath := t.lu.toInternalPath(oldNode.ID) - // update name attribute if err := xattr.Set(tgtPath, nameAttr, []byte(newNode.Name)); err != nil { return errors.Wrap(err, "ocisfs: could not set name attribute") @@ -173,9 +176,7 @@ func (t *Tree) Move(ctx context.Context, oldNode *Node, newNode *Node) (err erro return errors.Wrap(err, "ocisfs: could not move child") } - // update parentid and name - tgtPath := t.lu.toInternalPath(newNode.ID) - + // update target parentid and name if err := xattr.Set(tgtPath, parentidAttr, []byte(newNode.ParentID)); err != nil { return errors.Wrap(err, "ocisfs: could not set parentid attribute") } diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.txt b/tests/acceptance/expected-failures-on-OCIS-storage.txt index 3086a6c5b7..d46e975779 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.txt +++ b/tests/acceptance/expected-failures-on-OCIS-storage.txt @@ -1491,8 +1491,6 @@ apiVersions/fileVersionsSharingToShares.feature:179 # apiVersions/fileVersionsSharingToShares.feature:222 apiVersions/fileVersionsSharingToShares.feature:223 -apiVersions/fileVersionsSharingToShares.feature:224 -apiVersions/fileVersionsSharingToShares.feature:225 # # getting the metadata without permission results in a 403 error https://github.com/owncloud/ocis/issues/773 #