From 19ff7c9302aa9d76b679076ed3cadf85d716548f Mon Sep 17 00:00:00 2001 From: Brandon McNama Date: Sat, 16 May 2020 19:47:46 -0400 Subject: [PATCH] cache: Fix Server Side Copy with Temp Upload When wrapping a backend that supports Server Side Copy (e.g. `b2`, `s3`) and configuring the `tmp_upload_path` option, the `cache` backend would erroneously report that Server Side Copy/Move was not supported, causing operations such as file moves to fail. This change fixes this issue under these circumstances such that Server Side Copy will now be used when the wrapped backend supports it. Fixes #3206 --- backend/cache/cache.go | 6 +++--- cmd/backend/backend.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/cache/cache.go b/backend/cache/cache.go index 8b1263cad..98ebe79b0 100644 --- a/backend/cache/cache.go +++ b/backend/cache/cache.go @@ -520,9 +520,6 @@ func NewFs(name, rootPath string, m configmap.Mapper) (fs.Fs, error) { // override only those features that use a temp fs and it doesn't support them //f.features.ChangeNotify = f.ChangeNotify if f.opt.TempWritePath != "" { - if f.tempFs.Features().Copy == nil { - f.features.Copy = nil - } if f.tempFs.Features().Move == nil { f.features.Move = nil } @@ -1533,6 +1530,9 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, fs.Errorf(src, "source remote (%v) doesn't support Copy", src.Fs()) return nil, fs.ErrorCantCopy } + if f.opt.TempWritePath != "" && src.Fs() == f.tempFs { + return nil, fs.ErrorCantCopy + } // the source must be a cached object or we abort srcObj, ok := src.(*Object) if !ok { diff --git a/cmd/backend/backend.go b/cmd/backend/backend.go index 2d32ff447..12c5a3f33 100644 --- a/cmd/backend/backend.go +++ b/cmd/backend/backend.go @@ -59,7 +59,7 @@ Note to run these commands on a running backend then see [backend/command](/rc/#backend/command) in the rc docs. `, RunE: func(command *cobra.Command, args []string) error { - cmd.CheckArgs(2, 1E6, command, args) + cmd.CheckArgs(2, 1e6, command, args) name, remote := args[0], args[1] cmd.Run(false, false, command, func() error { // show help if remote is a backend name