Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

operations: Don't use multi-thread copy if the backend doesn't support it #6915

Nick Craig-Wood46a323ae1452
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) {