diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index f2f1fc852..520c5dbc2 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -47,6 +47,7 @@ import ( "github.com/rclone/rclone/fs/config/obscure" "github.com/rclone/rclone/fs/fserrors" "github.com/rclone/rclone/fs/hash" + "github.com/rclone/rclone/fs/operations" "github.com/rclone/rclone/lib/batcher" "github.com/rclone/rclone/lib/encoder" "github.com/rclone/rclone/lib/oauthutil" @@ -1020,13 +1021,20 @@ func (f *Fs) Precision() time.Duration { // Will only be called if src.Fs().Name() == f.Name() // // If it isn't possible then return fs.ErrorCantCopy -func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, error) { +func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Object, err error) { srcObj, ok := src.(*Object) if !ok { fs.Debugf(src, "Can't copy - not same remote type") return nil, fs.ErrorCantCopy } + // Find and remove existing object + cleanup, err := operations.RemoveExisting(ctx, f, remote, "server side copy") + if err != nil { + return nil, err + } + defer cleanup(&err) + // Temporary Object under construction dstObj := &Object{ fs: f, @@ -1040,7 +1048,6 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, ToPath: f.opt.Enc.FromStandardPath(dstObj.remotePath()), }, } - var err error var result *files.RelocationResult err = f.pacer.Call(func() (bool, error) { result, err = f.srv.CopyV2(&arg)