From 00062a687bb775dc0dd5b603ffa407c3f64b194e Mon Sep 17 00:00:00 2001 From: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:29:56 +0200 Subject: [PATCH] feat(proguard): Retry `upload-proguard` on 507 status (#2141) Closes #2140 --- src/api/errors/api_error.rs | 2 ++ src/api/mod.rs | 9 +++++++++ src/utils/http.rs | 1 + 3 files changed, 12 insertions(+) diff --git a/src/api/errors/api_error.rs b/src/api/errors/api_error.rs index 775f46d509..bbcfb93add 100644 --- a/src/api/errors/api_error.rs +++ b/src/api/errors/api_error.rs @@ -44,6 +44,8 @@ pub(in crate::api) enum ApiErrorKind { "DSN missing. Please set the `SENTRY_DSN` environment variable to your project's DSN." )] DsnMissing, + #[error("Error preparing request")] + ErrorPreparingRequest, } impl fmt::Display for ApiError { diff --git a/src/api/mod.rs b/src/api/mod.rs index e62975c096..dd17a0bdc9 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1411,6 +1411,15 @@ impl<'a> RegionSpecificApi<'a> { form.part("file").file(file).add()?; self.request(Method::Post, &path)? .with_form_data(form)? + .with_retry( + self.api.api.config.get_max_retry_count().map_err(|e| { + ApiError::with_source( + ApiErrorKind::ErrorPreparingRequest, + e.context("Could not parse retry count"), + ) + })?, + &[http::HTTP_STATUS_507_INSUFFICIENT_STORAGE], + )? .progress_bar_mode(ProgressBarMode::Request)? .send()? .convert() diff --git a/src/utils/http.rs b/src/utils/http.rs index 4cd345e443..11c98e188f 100644 --- a/src/utils/http.rs +++ b/src/utils/http.rs @@ -7,6 +7,7 @@ use regex::Regex; pub const HTTP_STATUS_502_BAD_GATEWAY: u32 = 502; pub const HTTP_STATUS_503_SERVICE_UNAVAILABLE: u32 = 503; pub const HTTP_STATUS_504_GATEWAY_TIMEOUT: u32 = 504; +pub const HTTP_STATUS_507_INSUFFICIENT_STORAGE: u32 = 507; lazy_static! { static ref LINK_TOKEN_RE: Regex = Regex::new(