Skip to content

Commit

Permalink
fix move in the owncloud storage driver (#1696)
Browse files Browse the repository at this point in the history
Update the filepath in redis when moving a file. Didn't implement it in delete since delete is still a bit more broken. But since we don't actively use the owncloud storage driver except for in CI it's not too important.

Fixes #1693
  • Loading branch information
C0rby authored May 10, 2021
1 parent b2ac93b commit 0fc001d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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")
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

0 comments on commit 0fc001d

Please sign in to comment.