Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retries #1573

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lychee-lib/src/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ pub(crate) trait RetryExt {
fn should_retry(&self) -> bool;
}

impl RetryExt for reqwest::Response {
impl RetryExt for reqwest::StatusCode {
/// Try to map a `reqwest` response into `Retryable`.
#[allow(clippy::if_same_then_else)]
fn should_retry(&self) -> bool {
let status = self.status();
let status = *self;
if status.is_server_error() {
true
} else if status.is_client_error()
Expand Down Expand Up @@ -71,10 +71,9 @@ impl RetryExt for reqwest::Error {
} else {
false
}
} else if let Some(status) = self.status() {
status.should_retry()
} else {
// We omit checking if error.is_status() since we check that already.
trask marked this conversation as resolved.
Show resolved Hide resolved
// However, if Response::error_for_status is used the status will still
// remain in the response object.
false
}
}
Expand Down
Loading