diff --git a/src/mako/api/lib/mbuild.mako b/src/mako/api/lib/mbuild.mako index 94abe2106b..b6af9cfd9a 100644 --- a/src/mako/api/lib/mbuild.mako +++ b/src/mako/api/lib/mbuild.mako @@ -800,7 +800,7 @@ else { let upload_result = { let url_str = &res.headers.get::().expect("Location header is part of protocol").0; if upload_url_from_server { - dlg.store_upload_url(url_str); + dlg.store_upload_url(Some(url_str)); } cmn::ResumableUploadHelper { @@ -832,6 +832,7 @@ else { res = upload_result; if !res.status.is_success() { ## delegate was called in upload() already - don't tell him again + dlg.store_upload_url(None); ${delegate_finish}(false); return Err(Error::Failure(res)) } diff --git a/src/rust/api/cmn.rs b/src/rust/api/cmn.rs index cd013bd649..44e55348f2 100644 --- a/src/rust/api/cmn.rs +++ b/src/rust/api/cmn.rs @@ -171,7 +171,10 @@ pub trait Delegate { /// Called after we have retrieved a new upload URL for a resumable upload to store it /// in case we fail or cancel. That way, we can attempt to resume the upload later, /// see `upload_url()`. - fn store_upload_url(&mut self, url: &str) { + /// It will also be called with None after a successful upload, which allows the delegate + /// to forget the URL. That way, we will not attempt to resume an upload that has already + /// finished. + fn store_upload_url(&mut self, url: Option<&str>) { let _ = url; }