Allow overlapping remotes in move when DirMove is supported
This commit is contained in:
parent
50b3cfccb1
commit
2058652fa4
3 changed files with 14 additions and 7 deletions
|
@ -15,7 +15,8 @@ var commandDefintion = &cobra.Command{
|
||||||
Short: `Move files from source to dest.`,
|
Short: `Move files from source to dest.`,
|
||||||
Long: `
|
Long: `
|
||||||
Moves the contents of the source directory to the destination
|
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
|
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
|
` + "`" + `source:path` + "`" + ` into ` + "`" + `dest:path` + "`" + `. After this ` + "`" + `source:path` + "`" + ` will no
|
||||||
|
|
13
fs/sync.go
13
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")
|
ErrorLog(fdst, "Nothing to do as source and destination are the same")
|
||||||
return nil
|
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
|
// 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() {
|
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
|
// Otherwise move the files one by one
|
||||||
return moveDir(fdst, fsrc)
|
return moveDir(fdst, fsrc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,6 +671,11 @@ func TestServerSideMoveWithFilter(t *testing.T) {
|
||||||
func TestServerSideMoveOverlap(t *testing.T) {
|
func TestServerSideMoveOverlap(t *testing.T) {
|
||||||
r := NewRun(t)
|
r := NewRun(t)
|
||||||
defer r.Finalise()
|
defer r.Finalise()
|
||||||
|
|
||||||
|
if _, ok := r.fremote.(fs.DirMover); ok {
|
||||||
|
t.Skip("Skipping test as remote supports DirMove")
|
||||||
|
}
|
||||||
|
|
||||||
subRemoteName := r.fremoteName + "/rclone-move-test"
|
subRemoteName := r.fremoteName + "/rclone-move-test"
|
||||||
fremoteMove, err := fs.NewFs(subRemoteName)
|
fremoteMove, err := fs.NewFs(subRemoteName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
Loading…
Reference in a new issue