Fix resumable uploads

Only increment the start offset when the response is successful and seek
to the start offset on each iteration.
This commit is contained in:
Petter Rasmussen
2021-06-06 15:08:33 +02:00
parent 18c4ea9ec9
commit 19088aa178

View File

@@ -694,8 +694,9 @@ impl<'a, A> ResumableUploadHelper<'a, A> {
_ => MIN_CHUNK_SIZE,
};
self.reader.seek(SeekFrom::Start(start)).unwrap();
loop {
self.reader.seek(SeekFrom::Start(start)).unwrap();
let request_size = match self.content_length - start {
rs if rs > chunk_size => chunk_size,
rs => rs,
@@ -711,7 +712,6 @@ impl<'a, A> ResumableUploadHelper<'a, A> {
}),
total_length: self.content_length,
};
start += request_size;
if self.delegate.cancel_chunk_upload(&range_header) {
return None;
}
@@ -730,6 +730,8 @@ impl<'a, A> ResumableUploadHelper<'a, A> {
.await;
match res {
Ok(res) => {
start += request_size;
if res.status() == StatusCode::PERMANENT_REDIRECT {
continue;
}