Skip to content

Commit 9d3922c

Browse files
committed
client: upload add thread sleep when error occur
1 parent f3b7537 commit 9d3922c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

client/src/upload_files.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::fs;
1414
use std::path::PathBuf;
1515
use std::sync::atomic::{AtomicU64, Ordering};
1616
use std::sync::Arc;
17+
use std::time::Duration;
1718
use tracing::warn;
1819
use walkdir::WalkDir;
1920

@@ -167,7 +168,7 @@ async fn retry_upload<T: Into<Cow<'static, str>> + Clone>(
167168
path: PathBuf,
168169
count: Arc<AtomicU64>,
169170
) -> Either<(String, u64), (String, u64)> {
170-
for retry in (0..3).into_iter() {
171+
for retry in (0..3:u32).into_iter() {
171172
let result = api
172173
.upload_file(domain.clone(), version.clone(), key.clone(), path.clone())
173174
.await;
@@ -179,6 +180,7 @@ async fn retry_upload<T: Into<Cow<'static, str>> + Clone>(
179180
}
180181
Err(e) => {
181182
warn!("key:{} upload fail at {}:\n{}", &key_string, retry + 1, e);
183+
tokio::time::sleep(Duration::from_secs(1<<(retry+1))).await;
182184
}
183185
}
184186
}

0 commit comments

Comments
 (0)