From 984eb8c9f7c6374bb6279a7c9c3ae451182dc295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Tue, 8 Mar 2022 14:22:02 +0100 Subject: [PATCH] fix notmuch backend infinite loop (#329) --- CHANGELOG.md | 2 ++ src/backends/id_mapper.rs | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c659e4..db714a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `In-Reply-To` not set properly when replying to a message [#323] - `Cc` missing or invalid when replying to a message [#324] +- Notmuch backend hangs [#329] ## [0.5.8] - 2022-03-04 @@ -497,3 +498,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#321]: https://github.com/soywod/himalaya/issues/321 [#323]: https://github.com/soywod/himalaya/issues/323 [#324]: https://github.com/soywod/himalaya/issues/324 +[#329]: https://github.com/soywod/himalaya/issues/329 diff --git a/src/backends/id_mapper.rs b/src/backends/id_mapper.rs index 953a729..09a5422 100644 --- a/src/backends/id_mapper.rs +++ b/src/backends/id_mapper.rs @@ -26,7 +26,6 @@ impl IdMapper { .open(&mapper.path) .context("cannot open id hash map file")?; let reader = BufReader::new(file); - for line in reader.lines() { let line = line.context("cannot read line from maildir envelopes id mapper cache file")?; @@ -83,13 +82,13 @@ impl IdMapper { for (hash, id) in self.iter() { loop { - let short_hash = &hash[0..self.short_hash_len]; + let short_hash = &hash[0..short_hash_len]; let conflict_found = self .map .keys() .find(|cached_hash| cached_hash.starts_with(short_hash) && cached_hash != &hash) .is_some(); - if self.short_hash_len > 32 || !conflict_found { + if short_hash_len > 32 || !conflict_found { break; } short_hash_len += 1;