"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
opendrive: fix retries of upload chunks - fixes #2646
Nick Craig-Woodc0ca93ae6feb
diff --git a/backend/opendrive/opendrive.go b/backend/opendrive/opendrive.goindex 352220e14..5cc4897d3 100644--- a/backend/opendrive/opendrive.go+++ b/backend/opendrive/opendrive.go@@ -21,6 +21,7 @@ import ("github.com/ncw/rclone/fs/hash""github.com/ncw/rclone/lib/dircache""github.com/ncw/rclone/lib/pacer"+ "github.com/ncw/rclone/lib/readers""github.com/ncw/rclone/lib/rest""github.com/pkg/errors")@@ -931,8 +932,9 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio// resp.Body.Close()// fs.Debugf(nil, "PostOpen: %#v", openResponse)- // 1 MB chunks size+ // 10 MB chunks sizechunkSize := int64(1024 * 1024 * 10)+ buf := make([]byte, int(chunkSize))chunkOffset := int64(0)remainingBytes := sizechunkCounter := 0@@ -945,14 +947,19 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptioremainingBytes -= currentChunkSizefs.Debugf(o, "Uploading chunk %d, size=%d, remain=%d", chunkCounter, currentChunkSize, remainingBytes)+ chunk := readers.NewRepeatableLimitReaderBuffer(in, buf, currentChunkSize)err = o.fs.pacer.Call(func() (bool, error) {+ // seek to the start in case this is a retry+ if _, err = chunk.Seek(0, io.SeekStart); err != nil {+ return false, err+ }var formBody bytes.Bufferw := multipart.NewWriter(&formBody)fw, err := w.CreateFormFile("file_data", o.remote)if err != nil {return false, err}- if _, err = io.CopyN(fw, in, currentChunkSize); err != nil {+ if _, err = io.Copy(fw, chunk); err != nil {return false, err}// Add session_id