From f6a053df6e0ec83a8a4fce9db436285d99cafba5 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 26 Jun 2016 21:10:20 +0100 Subject: [PATCH] Automatically set --no-traverse when copying a single file --- docs/content/docs.md | 28 ++++++++++++++++++++++++++++ rclone.go | 2 ++ 2 files changed, 30 insertions(+) diff --git a/docs/content/docs.md b/docs/content/docs.md index 07e80d89b..355053470 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -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 --------------------- diff --git a/rclone.go b/rclone.go index 5686117a1..bd261f48a 100644 --- a/rclone.go +++ b/rclone.go @@ -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()