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 move in the owncloud storage driver #1696

Merged
merged 1 commit into from
May 10, 2021
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
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-move-owncloud-driver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix move in owncloud storage driver

When moving a file or folder (includes renaming) the filepath in the cache didn't get updated which caused subsequent requests to `getpath` to fail.

https://github.com/cs3org/reva/issues/1693
https://github.com/cs3org/reva/issues/1696

21 changes: 21 additions & 0 deletions pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,27 @@ func (fs *ocfs) Move(ctx context.Context, oldRef, newRef *provider.Reference) (e
if err = os.Rename(oldIP, newIP); err != nil {
return errors.Wrap(err, "ocfs: error moving "+oldIP+" to "+newIP)
}

log := appctx.GetLogger(ctx)
conn := fs.pool.Get()
defer conn.Close()
// Ideally if we encounter an error here we should rollback the Move/Rename.
// But since the owncloud storage driver is not being actively used by anyone other
// than the acceptance tests we should be fine by ignoring the errors.
_ = filepath.Walk(newIP, func(path string, info os.FileInfo, err error) error {
if err != nil {
// TODO(c0rby): rollback the move in case of an error
log.Error().Str("path", path).Err(err).Msg("error caching id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a log about rolling back the whole op? And a TODO comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I opened an issue #1699
And added todos.

return nil
}
id := readOrCreateID(context.Background(), path, nil)
_, err = conn.Do("SET", id, path)
if err != nil {
// TODO(c0rby): rollback the move in case of an error
log.Error().Str("path", path).Err(err).Msg("error caching id")
}
return nil
})
if err := fs.propagate(ctx, newIP); err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions tests/acceptance/expected-failures-on-OWNCLOUD-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1624,8 +1624,6 @@ The following scenarios fail on OWNCLOUD storage but not on OCIS storage:

### [Moving resource loses associated shares](https://github.com/owncloud/ocis/issues/1251)

- [apiSharePublicLink2/multilinkSharing.feature:187](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/multilinkSharing.feature#L187)

#### [No way to set default folder for received shares](https://github.com/owncloud/ocis/issues/1327)
- [apiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:22](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L22)
- [apiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:23](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L23)
Expand Down