diff --git a/cmd/move/move.go b/cmd/move/move.go index dd0c422a2..fee132dd8 100644 --- a/cmd/move/move.go +++ b/cmd/move/move.go @@ -15,7 +15,8 @@ var commandDefintion = &cobra.Command{ Short: `Move files from source to dest.`, Long: ` Moves the contents of the source directory to the destination -directory. Rclone will error if the source and destination overlap. +directory. Rclone will error if the source and destination overlap and +the remote does not support a server side directory move operation. If no filters are in use and if possible this will server side move ` + "`" + `source:path` + "`" + ` into ` + "`" + `dest:path` + "`" + `. After this ` + "`" + `source:path` + "`" + ` will no diff --git a/fs/sync.go b/fs/sync.go index 2d7ccfc91..896191e00 100644 --- a/fs/sync.go +++ b/fs/sync.go @@ -455,12 +455,6 @@ func MoveDir(fdst, fsrc Fs) error { ErrorLog(fdst, "Nothing to do as source and destination are the same") return nil } - // The two remotes mustn't overlap - if Overlapping(fdst, fsrc) { - err := ErrorCantMoveOverlapping - ErrorLog(fdst, "%v", err) - return err - } // First attempt to use DirMover if exists, same Fs and no filters are active if fdstDirMover, ok := fdst.(DirMover); ok && fsrc.Name() == fdst.Name() && Config.Filter.InActive() { @@ -483,6 +477,13 @@ func MoveDir(fdst, fsrc Fs) error { } } + // The two remotes mustn't overlap if we didn't do server side move + if Overlapping(fdst, fsrc) { + err := ErrorCantMoveOverlapping + ErrorLog(fdst, "%v", err) + return err + } + // Otherwise move the files one by one return moveDir(fdst, fsrc) } diff --git a/fs/sync_test.go b/fs/sync_test.go index df2227176..fcf44bea6 100644 --- a/fs/sync_test.go +++ b/fs/sync_test.go @@ -671,6 +671,11 @@ func TestServerSideMoveWithFilter(t *testing.T) { func TestServerSideMoveOverlap(t *testing.T) { r := NewRun(t) defer r.Finalise() + + if _, ok := r.fremote.(fs.DirMover); ok { + t.Skip("Skipping test as remote supports DirMove") + } + subRemoteName := r.fremoteName + "/rclone-move-test" fremoteMove, err := fs.NewFs(subRemoteName) require.NoError(t, err)