mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:30:06 +08:00
vfs: Implement renaming of directories for backends without DirMove #2539
Previously to this change, backends without the optional interface DirMove could not rename directories. This change uses the new operations.DirMove call to implement renaming directories which will fall back to Move/Copy as necessary.
This commit is contained in:
parent
bbd03f49a4
commit
53a8b5a275
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
"github.com/ncw/rclone/fs/list"
|
"github.com/ncw/rclone/fs/list"
|
||||||
|
"github.com/ncw/rclone/fs/operations"
|
||||||
"github.com/ncw/rclone/fs/walk"
|
"github.com/ncw/rclone/fs/walk"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -576,15 +577,15 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case fs.Directory:
|
case fs.Directory:
|
||||||
doDirMove := d.f.Features().DirMove
|
features := d.f.Features()
|
||||||
if doDirMove == nil {
|
if features.DirMove == nil && features.Move == nil && features.Copy == nil {
|
||||||
err := errors.Errorf("Fs %q can't rename directories (no DirMove)", d.f)
|
err := errors.Errorf("Fs %q can't rename directories (no DirMove, Move or Copy)", d.f)
|
||||||
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
srcRemote := x.Remote()
|
srcRemote := x.Remote()
|
||||||
dstRemote := newPath
|
dstRemote := newPath
|
||||||
err = doDirMove(d.f, srcRemote, dstRemote)
|
err = operations.DirMove(d.f, srcRemote, dstRemote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user