"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
operations: fix OpenOptions ignored in copy if operation was a multiThreadCopy
Vitor Gomes48a8bfa6b314
diff --git a/fs/operations/multithread.go b/fs/operations/multithread.goindex 9b79e6fa1..e5357dc0b 100644--- a/fs/operations/multithread.go+++ b/fs/operations/multithread.go@@ -127,7 +127,7 @@ func calculateNumChunks(size int64, chunkSize int64) int {// Copy src to (f, remote) using streams download threads. It tries to use the OpenChunkWriter feature// and if that's not available it creates an adapter using OpenWriterAt-func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object, concurrency int, tr *accounting.Transfer) (newDst fs.Object, err error) {+func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object, concurrency int, tr *accounting.Transfer, options ...fs.OpenOption) (newDst fs.Object, err error) {openChunkWriter := f.Features().OpenChunkWriterci := fs.GetConfig(ctx)noseek := false@@ -148,7 +148,7 @@ func multiThreadCopy(ctx context.Context, f fs.Fs, remote string, src fs.Object,return nil, fmt.Errorf("multi-thread copy: can't copy zero sized file")}- info, chunkWriter, err := openChunkWriter(ctx, remote, src)+ info, chunkWriter, err := openChunkWriter(ctx, remote, src, options...)if err != nil {return nil, fmt.Errorf("multi-thread copy: failed to open chunk writer: %w", err)}diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex 3c1ced8db..262f9fedd 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -422,8 +422,17 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.ObjremoveFailedPartialCopy(ctx, f, remotePartial)})}++ uploadOptions := []fs.OpenOption{hashOption}+ for _, option := range ci.UploadHeaders {+ uploadOptions = append(uploadOptions, option)+ }+ if ci.MetadataSet != nil {+ uploadOptions = append(uploadOptions, fs.MetadataOption(ci.MetadataSet))+ }+if doMultiThreadCopy(ctx, f, src) {- dst, err = multiThreadCopy(ctx, f, remotePartial, src, ci.MultiThreadStreams, tr)+ dst, err = multiThreadCopy(ctx, f, remotePartial, src, ci.MultiThreadStreams, tr, uploadOptions...)if err == nil {newDst = dst}@@ -467,17 +476,10 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Objif src.Remote() != remotePartial {wrappedSrc = fs.NewOverrideRemote(src, remotePartial)}- options := []fs.OpenOption{hashOption}- for _, option := range ci.UploadHeaders {- options = append(options, option)- }- if ci.MetadataSet != nil {- options = append(options, fs.MetadataOption(ci.MetadataSet))- }if doUpdate && inplace {- err = dst.Update(ctx, in, wrappedSrc, options...)+ err = dst.Update(ctx, in, wrappedSrc, uploadOptions...)} else {- dst, err = f.Put(ctx, in, wrappedSrc, options...)+ dst, err = f.Put(ctx, in, wrappedSrc, uploadOptions...)}if doUpdate {actionTaken = "Copied (replaced existing)"