Exemple #1
0
func TestCopyFile(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()

	file1 := r.WriteFile("file1", "file1 contents", t1)
	fstest.CheckItems(t, r.flocal, file1)

	file2 := file1
	file2.Path = "sub/file2"

	r.Mkdir(r.fremote)
	err := fs.CopyFile(r.fremote, r.flocal, file2.Path, file1.Path)
	require.NoError(t, err)
	fstest.CheckItems(t, r.flocal, file1)
	fstest.CheckItems(t, r.fremote, file2)

	err = fs.CopyFile(r.fremote, r.flocal, file2.Path, file1.Path)
	require.NoError(t, err)
	fstest.CheckItems(t, r.flocal, file1)
	fstest.CheckItems(t, r.fremote, file2)
}
Exemple #2
0
So

    rclone copyto src dst

where src and dst are rclone paths, either remote:path or
/path/to/local or C:\windows\path\if\on\windows.

This will:

    if src is file
        copy it to dst, overwriting an existing file if it exists
    if src is directory
        copy it to dst, overwriting existing files if they exist
        see copy command for full details

This doesn't transfer unchanged files, testing by size and
modification time or MD5SUM.  It doesn't delete files from the
destination.
`,
	Run: func(command *cobra.Command, args []string) {
		cmd.CheckArgs(2, 2, command, args)
		fsrc, srcFileName, fdst, dstFileName := cmd.NewFsSrcDstFiles(args)
		cmd.Run(true, true, command, func() error {
			if srcFileName == "" {
				return fs.CopyDir(fdst, fsrc)
			}
			return fs.CopyFile(fdst, fsrc, dstFileName, srcFileName)
		})
	},
}