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

b2: fix multipart upload retries #1733

Nick Craig-Wood0914ec316c65
diff --git a/b2/upload.go b/b2/upload.go
index dbf53731e..18c17e3c9 100644
--- a/b2/upload.go
+++ b/b2/upload.go
@@ -182,9 +182,6 @@ func (up *largeUpload) clearUploadURL() {
// Transfer a chunk
func (up *largeUpload) transferChunk(part int64, body []byte) error {
- in := newHashAppendingReader(bytes.NewReader(body), sha1.New())
- size := int64(len(body)) + int64(in.AdditionalLength())
-
err := up.f.pacer.Call(func() (bool, error) {
fs.Debugf(up.o, "Sending chunk %d length %d", part, len(body))
@@ -194,6 +191,9 @@ func (up *largeUpload) transferChunk(part int64, body []byte) error {
return false, err
}
+ in := newHashAppendingReader(bytes.NewReader(body), sha1.New())
+ size := int64(len(body)) + int64(in.AdditionalLength())
+
// Authorization
//
// An upload authorization token, from b2_get_upload_part_url.
@@ -238,6 +238,7 @@ func (up *largeUpload) transferChunk(part int64, body []byte) error {
upload = nil
}
up.returnUploadURL(upload)
+ up.sha1s[part-1] = in.HexSum()
return retry, err
})
if err != nil {
@@ -245,7 +246,6 @@ func (up *largeUpload) transferChunk(part int64, body []byte) error {
} else {
fs.Debugf(up.o, "Done sending chunk %d", part)
}
- up.sha1s[part-1] = in.HexSum()
return err
}