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 ocis move #1343

Merged
merged 1 commit into from
Nov 30, 2020
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
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