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: retry only reqwest errors #269

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Changes from all commits
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
12 changes: 7 additions & 5 deletions uplink/src/collector/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,22 @@ impl FileDownloader {

// Retry mechanism tries atleast 3 times before returning an error
async fn retry_thrice(&mut self, action: Action) -> Result<(), Error> {
let mut res = Ok(());
for _ in 0..3 {
match self.run(action.clone()).await {
Ok(_) => return Ok(()),
Ok(_) => break,
Err(e) => {
error!("Download failed: {e}");
res = Err(e);
if let Error::Reqwest(e) = e {
error!("Download failed: {e}");
} else {
return Err(e);
}
}
}
tokio::time::sleep(Duration::from_secs(30)).await;
warn!("Retrying download");
}

res
Ok(())
}

// Accepts a download `Action` and performs necessary data extraction to actually download the file
Expand Down
Loading