From 2dac4374f3405b1457fb2ea6652ae5f4b06fd7a7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 23 Dec 2024 08:24:14 +0000 Subject: [PATCH] fix(trello): detect trello 429 responses correctly --- src/macros/backoff.rs | 3 +++ src/trello/client.rs | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/macros/backoff.rs b/src/macros/backoff.rs index 778ebce..f0dd6cc 100644 --- a/src/macros/backoff.rs +++ b/src/macros/backoff.rs @@ -30,6 +30,9 @@ macro_rules! with_exponential_backoff { { $crate::backoff!(backoff_secs, $ctx) } + Ok(response) if response.status() == kxio::net::StatusCode::TOO_MANY_REQUESTS => { + $crate::backoff!(backoff_secs, $ctx) + } result => break result, } } diff --git a/src/trello/client.rs b/src/trello/client.rs index cf25921..7483dfe 100644 --- a/src/trello/client.rs +++ b/src/trello/client.rs @@ -92,11 +92,10 @@ impl<'ctx> TrelloClient<'ctx> { .headers(self.auth_headers()) .header("accept", "application/octet") .send() - .await? - .bytes() .await - .map_err(Into::into) - ) + )? + .bytes() + .await .context("downloading attachment")?; let file = fs.file(&file_name); file.write(resp)