fix notmuch backend infinite loop (#329)

This commit is contained in:
Clément DOUIN 2022-03-08 14:22:02 +01:00
parent 3899ec9c03
commit 984eb8c9f7
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
2 changed files with 4 additions and 3 deletions

View file

@ -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

View file

@ -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;