summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/cli/src/modules/export.rs56
-rw-r--r--crates/imap/src/op/authenticate.rs12
2 files changed, 37 insertions, 31 deletions
diff --git a/crates/cli/src/modules/export.rs b/crates/cli/src/modules/export.rs
index 1bb6aeeb..a2ac9b3d 100644
--- a/crates/cli/src/modules/export.rs
+++ b/crates/cli/src/modules/export.rs
@@ -82,34 +82,36 @@ impl ExportCommands {
let mut blob_path = path.clone();
blob_path.push(&blob_id);
- futures.push(async move {
- let mut retry_count = 0;
-
- let bytes = loop {
- match client.download(&blob_id).await {
- Ok(bytes) => break bytes,
- Err(_) if retry_count < RETRY_ATTEMPTS => {
- tokio::time::sleep(std::time::Duration::from_secs(1)).await;
- retry_count += 1;
+ if tokio::fs::metadata(&blob_path).await.is_err() {
+ futures.push(async move {
+ let mut retry_count = 0;
+
+ let bytes = loop {
+ match client.download(&blob_id).await {
+ Ok(bytes) => break bytes,
+ Err(_) if retry_count < RETRY_ATTEMPTS => {
+ tokio::time::sleep(std::time::Duration::from_secs(1)).await;
+ retry_count += 1;
+ }
+ result => {
+ result.unwrap_result("download blob");
+ return;
+ }
}
- result => {
- result.unwrap_result("download blob");
- return;
- }
- }
- };
-
- tokio::fs::OpenOptions::new()
- .create(true)
- .write(true)
- .truncate(true)
- .open(&blob_path)
- .await
- .unwrap_result(&format!("open {}", blob_path.display()))
- .write_all(&bytes)
- .await
- .unwrap_result(&format!("write {}", blob_path.display()));
- });
+ };
+
+ tokio::fs::OpenOptions::new()
+ .create(true)
+ .write(true)
+ .truncate(true)
+ .open(&blob_path)
+ .await
+ .unwrap_result(&format!("open {}", blob_path.display()))
+ .write_all(&bytes)
+ .await
+ .unwrap_result(&format!("write {}", blob_path.display()));
+ });
+ }
if futures.len() == num_concurrent {
futures.next().await.unwrap();
diff --git a/crates/imap/src/op/authenticate.rs b/crates/imap/src/op/authenticate.rs
index 5846bb44..d85d5d57 100644
--- a/crates/imap/src/op/authenticate.rs
+++ b/crates/imap/src/op/authenticate.rs
@@ -233,10 +233,14 @@ pub fn decode_challenge_plain(challenge: &[u8]) -> Result<Credentials<String>, &
let mut arg_num = 0;
for &ch in challenge {
if ch != 0 {
- if arg_num == 1 {
- username.push(ch);
- } else if arg_num == 2 {
- secret.push(ch);
+ match arg_num.cmp(&2) {
+ std::cmp::Ordering::Less => {
+ username.push(ch);
+ }
+ std::cmp::Ordering::Equal => {
+ secret.push(ch);
+ }
+ std::cmp::Ordering::Greater => (),
}
} else {
arg_num += 1;