From 46a323ae1452f312bbe68786c6dcc79d0483d1a3 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 9 May 2023 17:40:58 +0100 Subject: [PATCH] operations: Don't use multi-thread copy if the backend doesn't support it #6915 --- fs/operations/multithread.go | 6 +++++- fs/operations/multithread_test.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/operations/multithread.go b/fs/operations/multithread.go index b8ace21d5..62812dc00 100644 --- a/fs/operations/multithread.go +++ b/fs/operations/multithread.go @@ -28,11 +28,15 @@ func doMultiThreadCopy(ctx context.Context, f fs.Fs, src fs.Object) bool { if ci.MultiThreadStreams <= 1 { return false } + // ...if the source doesn't support it + if src.Fs().Features().NoMultiThreading { + return false + } // ...size of object is less than cutoff if src.Size() < int64(ci.MultiThreadCutoff) { return false } - // ...source doesn't support it + // ...destination doesn't support it dstFeatures := f.Features() if dstFeatures.OpenWriterAt == nil { return false diff --git a/fs/operations/multithread_test.go b/fs/operations/multithread_test.go index fa982cf59..aef6f75af 100644 --- a/fs/operations/multithread_test.go +++ b/fs/operations/multithread_test.go @@ -79,6 +79,11 @@ func TestDoMultiThreadCopy(t *testing.T) { assert.True(t, doMultiThreadCopy(ctx, f, src)) srcFs.Features().IsLocal = false assert.True(t, doMultiThreadCopy(ctx, f, src)) + + srcFs.Features().NoMultiThreading = true + assert.False(t, doMultiThreadCopy(ctx, f, src)) + srcFs.Features().NoMultiThreading = false + assert.True(t, doMultiThreadCopy(ctx, f, src)) } func TestMultithreadCalculateChunks(t *testing.T) {