fix missing range when fetch fails, add more logs (#276)

This commit is contained in:
Clément DOUIN 2022-02-01 13:06:46 +01:00
parent d513afdd16
commit 0172edcb3f
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
2 changed files with 10 additions and 2 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Blur in list msg screenshot [#181] - Blur in list msg screenshot [#181]
- Make inbox, sent and drafts folders customizable [#172] - Make inbox, sent and drafts folders customizable [#172]
- Nix run issue [#272] - Nix run issue [#272]
- Range not displayed when fetch fails [#276]
### Removed ### Removed
@ -368,3 +369,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#229]: https://github.com/soywod/himalaya/issues/229 [#229]: https://github.com/soywod/himalaya/issues/229
[#272]: https://github.com/soywod/himalaya/issues/272 [#272]: https://github.com/soywod/himalaya/issues/272
[#273]: https://github.com/soywod/himalaya/issues/273 [#273]: https://github.com/soywod/himalaya/issues/273
[#276]: https://github.com/soywod/himalaya/issues/276

View file

@ -121,12 +121,17 @@ impl<'a> ImapServiceInterface<'a> for ImapService<'a> {
} }
fn fetch_envelopes(&mut self, page_size: &usize, page: &usize) -> Result<Envelopes> { fn fetch_envelopes(&mut self, page_size: &usize, page: &usize) -> Result<Envelopes> {
debug!("fetch envelopes");
debug!("page size: {:?}", page_size);
debug!("page: {:?}", page);
let mbox = self.mbox.to_owned(); let mbox = self.mbox.to_owned();
let last_seq = self let last_seq = self
.sess()? .sess()?
.select(&mbox.name) .select(&mbox.name)
.context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))? .context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?
.exists as i64; .exists as i64;
debug!("last sequence number: {:?}", last_seq);
if last_seq == 0 { if last_seq == 0 {
return Ok(Envelopes::default()); return Ok(Envelopes::default());
@ -141,11 +146,12 @@ impl<'a> ImapServiceInterface<'a> for ImapService<'a> {
} else { } else {
String::from("1:*") String::from("1:*")
}; };
debug!("range: {:?}", range);
let fetches = self let fetches = self
.sess()? .sess()?
.fetch(range, "(ENVELOPE FLAGS INTERNALDATE)") .fetch(&range, "(ENVELOPE FLAGS INTERNALDATE)")
.context(r#"cannot fetch messages within range "{}""#)?; .context(format!(r#"cannot fetch messages within range "{}""#, range))?;
self._raw_msgs_cache = Some(fetches); self._raw_msgs_cache = Some(fetches);
Envelopes::try_from(self._raw_msgs_cache.as_ref().unwrap()) Envelopes::try_from(self._raw_msgs_cache.as_ref().unwrap())
} }