Skip to content

Commit

Permalink
fix move in the owncloud storage driver
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 cs3org#1693
  • Loading branch information
David Christofas committed May 10, 2021
1 parent e2c3841 commit 6abb674
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 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

19 changes: 19 additions & 0 deletions pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,25 @@ 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 {
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 {
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

0 comments on commit 6abb674

Please sign in to comment.