diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-09-16 19:46:11 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-09-16 19:46:11 +0300 |
commit | e8f3b6aa24b33f79b04a16b424284bc3ac752808 (patch) | |
tree | eadbb520f7c1308b4a835484389e47a6a5a8fce5 /melib/src/backends | |
parent | 64a2af377756f5525eb0b31fe1d4e872761943d7 (diff) |
melib/imap: check for max uid == 0 when resyncing
Diffstat (limited to 'melib/src/backends')
-rw-r--r-- | melib/src/backends/imap/cache.rs | 2 | ||||
-rw-r--r-- | melib/src/backends/imap/cache/sync.rs | 33 |
2 files changed, 25 insertions, 10 deletions
diff --git a/melib/src/backends/imap/cache.rs b/melib/src/backends/imap/cache.rs index ad2b1301..d89512f2 100644 --- a/melib/src/backends/imap/cache.rs +++ b/melib/src/backends/imap/cache.rs @@ -539,7 +539,7 @@ mod sqlite3_m { } } tx.commit()?; - let new_max_uid = self.max_uid(mailbox_hash)?; + let new_max_uid = self.max_uid(mailbox_hash).unwrap_or(0); self.uid_store .max_uids .lock() diff --git a/melib/src/backends/imap/cache/sync.rs b/melib/src/backends/imap/cache/sync.rs index 861f3cb8..60450acc 100644 --- a/melib/src/backends/imap/cache/sync.rs +++ b/melib/src/backends/imap/cache/sync.rs @@ -261,8 +261,12 @@ impl ImapConnection { .unwrap() .insert_existing_set(payload.iter().map(|(_, env)| env.hash()).collect::<_>()); // 3. tag2 UID FETCH 1:<lastseenuid> FLAGS - self.send_command(format!("UID FETCH 1:{} FLAGS", max_uid).as_bytes()) - .await?; + if max_uid == 0 { + self.send_command("UID FETCH 1:* FLAGS".as_bytes()).await?; + } else { + self.send_command(format!("UID FETCH 1:{} FLAGS", max_uid).as_bytes()) + .await?; + } self.read_response(&mut response, RequiredResponses::FETCH_REQUIRED) .await?; //1) update cached flags for old messages; @@ -539,14 +543,25 @@ impl ImapConnection { .unwrap() .insert_existing_set(payload.iter().map(|(_, env)| env.hash()).collect::<_>()); // 3. tag2 UID FETCH 1:<lastseenuid> FLAGS - self.send_command( - format!( - "UID FETCH 1:{} FLAGS (CHANGEDSINCE {})", - cached_max_uid, cached_highestmodseq + if cached_max_uid == 0 { + self.send_command( + format!( + "UID FETCH 1:* FLAGS (CHANGEDSINCE {})", + cached_highestmodseq + ) + .as_bytes(), ) - .as_bytes(), - ) - .await?; + .await?; + } else { + self.send_command( + format!( + "UID FETCH 1:{} FLAGS (CHANGEDSINCE {})", + cached_max_uid, cached_highestmodseq + ) + .as_bytes(), + ) + .await?; + } self.read_response(&mut response, RequiredResponses::FETCH_REQUIRED) .await?; //1) update cached flags for old messages; |