From 2f424ceecfbb7a49a02bb7468b0759beb5f4f7ce Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 24 Aug 2023 17:23:07 +0100 Subject: [PATCH] operations: don't buffer when a backend implements OpenWriterAt In this case we don't seek on errors so no need for seeking. --- fs/operations/multithread.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/operations/multithread.go b/fs/operations/multithread.go index 8cb78dc0a..a780bfd15 100644 --- a/fs/operations/multithread.go +++ b/fs/operations/multithread.go @@ -135,12 +135,15 @@ func calculateNumChunks(size int64, chunkSize int64) int { func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object, streams int, tr *accounting.Transfer) (newDst fs.Object, err error) { openChunkWriter := f.Features().OpenChunkWriter ci := fs.GetConfig(ctx) + noseek := false if openChunkWriter == nil { openWriterAt := f.Features().OpenWriterAt if openWriterAt == nil { return nil, errors.New("multi-thread copy: neither OpenChunkWriter nor OpenWriterAt supported") } openChunkWriter = openChunkWriterFromOpenWriterAt(openWriterAt, int64(ci.MultiThreadChunkSize), int64(ci.MultiThreadWriteBufferSize), f) + // We don't seek the chunks with OpenWriterAt + noseek = true } if src.Size() < 0 { @@ -184,7 +187,7 @@ func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object, partSize: chunkSize, streams: streams, numChunks: numChunks, - noSeek: f.Features().PartialUploads, + noSeek: noseek, } // Make accounting