Skip to content

Commit 5b96463

Browse files
committed
refactor: add last source error to failed retry of upload / download
It was missing for aggregator file upload and client database v2 download.
1 parent 97c1fc4 commit 5b96463

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

mithril-aggregator/src/file_uploaders/interface.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ pub trait FileUploader: Sync + Send {
5353
nb_attempts += 1;
5454
match self.upload_without_retry(filepath).await {
5555
Ok(result) => return Ok(result),
56-
Err(_) if nb_attempts >= retry_policy.attempts => {
57-
return Err(anyhow::anyhow!(
58-
"Upload failed after {} attempts",
59-
nb_attempts
60-
));
56+
Err(e) if nb_attempts >= retry_policy.attempts => {
57+
return Err(anyhow::anyhow!(e).context(format!(
58+
"Upload failed after {nb_attempts} attempts. Uploaded file path: {}",
59+
filepath.display()
60+
)));
6161
}
6262
_ => tokio::time::sleep(retry_policy.delay_between_attempts).await,
6363
}

mithril-client/src/file_downloader/retry.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ impl FileDownloader for RetryDownloader {
8181
.await
8282
{
8383
Ok(result) => return Ok(result),
84-
Err(_) if nb_attempts >= retry_policy.attempts => {
85-
return Err(anyhow::anyhow!(
86-
"Download of location {:?} failed after {} attempts",
87-
location,
88-
nb_attempts
89-
));
84+
Err(e) if nb_attempts >= retry_policy.attempts => {
85+
return Err(anyhow::anyhow!(e).context(format!(
86+
"Download of location {location:?} failed after {nb_attempts} attempts",
87+
)));
9088
}
9189
_ => tokio::time::sleep(retry_policy.delay_between_attempts).await,
9290
}

0 commit comments

Comments
 (0)