Automatically set --no-traverse when copying a single file

This commit is contained in:
Nick Craig-Wood 2016-06-26 21:10:20 +01:00
parent af4ef8ad8d
commit f6a053df6e
2 changed files with 30 additions and 0 deletions

View File

@ -284,6 +284,34 @@ Enter an interactive configuration session.
Prints help on rclone commands and options.
Copying single files
--------------------
rclone normally syncs or copies directories. However if the source
remote points to a file, rclone will just copy that file. The
destination remote must point to a directory - rclone will give the
error `Failed to create file system for "remote:file": is a file not a
directory` if it isn't.
For example, suppose you have a remote with a file in called
`test.jpg`, then you could copy just that file like this
rclone copy remote:test.jpg /tmp/download
The file `test.jpg` will be placed inside `/tmp/download`.
This is equivalent to specifying
rclone copy --no-traverse --files-from /tmp/files remote: /tmp/download
Where `/tmp/files` contains the single line
test.jpg
It is recommended to use `copy` when copying single files not `sync`.
They have pretty much the same effect but `copy` will use a lot less
memory.
Quoting and the shell
---------------------

View File

@ -384,6 +384,8 @@ func NewFsSrc(remote string) fs.Fs {
}
// Limit transfers to this file
err = fs.Config.Filter.AddFile(path.Base(fsPath))
// Set --no-traverse as only one file
fs.Config.NoTraverse = true
}
if err != nil {
fs.Stats.Error()