From 5c4ef2c560a99a31d3bded76503fd704970bdd3b Mon Sep 17 00:00:00 2001 From: Diavolo Date: Tue, 12 Dec 2023 17:27:42 +0100 Subject: [PATCH 1/3] fix: reacquire missing files --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1067afe..56cfc81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,6 +219,11 @@ async fn update_dir( .unwrap_or_else(|| Cow::Owned(misc::get_file_sha1(&file_path))) .to_string(); + // Because we don't know here what happened in the call unwrap_or_else above we quietly double-check if the file is missing or not + if !file_path.exists() { + sha1_local = ""; + } + if sha1_local != sha1_remote { files_to_download.push(file.clone()); } else { From 7f4095adbe3077840ac31a8b3510bc0df75d6e7d Mon Sep 17 00:00:00 2001 From: Diavolo Date: Tue, 12 Dec 2023 17:32:57 +0100 Subject: [PATCH 2/3] use .clear --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 56cfc81..db9f99b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -221,7 +221,7 @@ async fn update_dir( // Because we don't know here what happened in the call unwrap_or_else above we quietly double-check if the file is missing or not if !file_path.exists() { - sha1_local = ""; + sha1_local.clear(); } if sha1_local != sha1_remote { From 08611edf28a18ee6c1615255c3207c5213d84ef7 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Tue, 12 Dec 2023 17:35:37 +0100 Subject: [PATCH 3/3] become mutable and shutup --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index db9f99b..a0cab01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,7 +213,7 @@ async fn update_dir( let file_name = &file.name.replace(remote_dir_pre.as_str(), ""); let file_path = dir.join(file_name); if file_path.exists() { - let sha1_local = hashes + let mut sha1_local = hashes .get(file_name) .map(Cow::Borrowed) .unwrap_or_else(|| Cow::Owned(misc::get_file_sha1(&file_path)))