From 19088aa1787e7e3a6406cba4d509441c056e6f02 Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Sun, 6 Jun 2021 15:08:33 +0200 Subject: [PATCH] Fix resumable uploads Only increment the start offset when the response is successful and seek to the start offset on each iteration. --- src/rust/api/client.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rust/api/client.rs b/src/rust/api/client.rs index 8e46ef0407..37ab5b5ab3 100644 --- a/src/rust/api/client.rs +++ b/src/rust/api/client.rs @@ -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; }