去掉产物下载重试里的不可达panic分支
- download_artifact 原先用 for + last_error + expect 收尾,循环每轮都会 return,expect 实际不可达,却给库留下一条潜在 panic 路径 - 改为 loop 内递增 attempt,重试耗尽时直接返回最后一次错误,重试次数与退避行为不变
This commit is contained in:
@@ -74,20 +74,18 @@ impl TripoProviderClient {
|
||||
url: &TripoUrl,
|
||||
) -> Result<TripoDownloadedArtifact, TripoError> {
|
||||
let total_attempts = self.artifact_retries.saturating_add(1);
|
||||
let mut last_error = None;
|
||||
let mut attempt = 1;
|
||||
|
||||
for attempt in 1..=total_attempts {
|
||||
loop {
|
||||
match self.download_artifact_once(task_id, url).await {
|
||||
Ok(downloaded) => return Ok(downloaded),
|
||||
Err(error) if attempt < total_attempts && error.is_retryable() => {
|
||||
last_error = Some(error);
|
||||
tokio::time::sleep(download_backoff(attempt)).await;
|
||||
attempt += 1;
|
||||
}
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
|
||||
Err(last_error.expect("artifact download has at least one attempt"))
|
||||
}
|
||||
|
||||
async fn download_artifact_once(
|
||||
|
||||
Reference in New Issue
Block a user