Skip to content

Commit

Permalink
fix ocis move (cs3org#1343)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic authored Nov 30, 2020
1 parent e4fc511 commit ac85e68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-ocis-move.md
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions pkg/storage/fs/ocis/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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")
Expand All @@ -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")
}
Expand Down
2 changes: 0 additions & 2 deletions tests/acceptance/expected-failures-on-OCIS-storage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down

0 comments on commit ac85e68

Please sign in to comment.