From 71f288356258f65d08ac0f8bcc86fdf067e77310 Mon Sep 17 00:00:00 2001 From: Pat Patterson Date: Tue, 12 Sep 2023 23:18:06 -0700 Subject: [PATCH] operations: ensure concurrency is no greater than the number of chunks - fixes #7299 --- fs/operations/multithread.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/operations/multithread.go b/fs/operations/multithread.go index e4b75c62c..9b79e6fa1 100644 --- a/fs/operations/multithread.go +++ b/fs/operations/multithread.go @@ -172,17 +172,18 @@ func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object, info.ChunkSize = src.Size() } + // Use the backend concurrency if it is higher than --multi-thread-streams or if --multi-thread-streams wasn't set explicitly + if !ci.MultiThreadSet || info.Concurrency > concurrency { + fs.Debugf(src, "multi-thread copy: using backend concurrency of %d instead of --multi-thread-streams %d", info.Concurrency, concurrency) + concurrency = info.Concurrency + } + numChunks := calculateNumChunks(src.Size(), info.ChunkSize) if concurrency > numChunks { fs.Debugf(src, "multi-thread copy: number of streams %d was bigger than number of chunks %d", concurrency, numChunks) concurrency = numChunks } - // Use the backend concurrency if it is higher than --multi-thread-streams or if --multi-thread-streams wasn't set explicitly - if !ci.MultiThreadSet || info.Concurrency > concurrency { - fs.Debugf(src, "multi-thread copy: using backend concurrency of %d instead of --multi-thread-streams %d", info.Concurrency, concurrency) - concurrency = info.Concurrency - } if concurrency < 1 { concurrency = 1 }