aboutsummaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-13 14:21:14 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-13 14:21:14 +0200
commitcd59be3a007822637a8b48efe988fb052d58a756 (patch)
tree4f57f0720ed62e9c8704a6ca38a6a4c48b660f6d /src/imap
parent9fa2e958b3b37538b80b7f26107b7df2238f335b (diff)
downloadaerogramme-cd59be3a007822637a8b48efe988fb052d58a756.tar.gz
aerogramme-cd59be3a007822637a8b48efe988fb052d58a756.zip
Implement opportunistic sync based on watch value, and use it
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/command/examined.rs4
-rw-r--r--src/imap/mailbox_view.rs18
2 files changed, 11 insertions, 11 deletions
diff --git a/src/imap/command/examined.rs b/src/imap/command/examined.rs
index 94e8e88..8da68f8 100644
--- a/src/imap/command/examined.rs
+++ b/src/imap/command/examined.rs
@@ -87,7 +87,9 @@ impl<'a> ExaminedContext<'a> {
}
pub async fn noop(self) -> Result<(Response, flow::Transition)> {
- let updates = self.mailbox.sync_update().await?;
+ self.mailbox.mailbox.force_sync().await?;
+
+ let updates = self.mailbox.update().await?;
Ok((
Response::ok("NOOP completed.")?.with_body(updates),
flow::Transition::None,
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index 5debcb9..9941428 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -68,16 +68,10 @@ impl MailboxView {
Ok((new_view, data))
}
- /// Looks up state changes in the mailbox and produces a set of IMAP
- /// responses describing the changes.
- pub async fn sync_update(&mut self) -> Result<Vec<Body>> {
- self.mailbox.sync().await?;
-
- self.update().await
- }
-
/// Produces a set of IMAP responses describing the change between
/// what the client knows and what is actually in the mailbox.
+ /// This does NOT trigger a sync, it bases itself on what is currently
+ /// loaded in RAM by Bayou.
pub async fn update(&mut self) -> Result<Vec<Body>> {
let new_view = MailboxView {
mailbox: self.mailbox.clone(),
@@ -156,6 +150,8 @@ impl MailboxView {
flags: &[Flag],
uid: &bool,
) -> Result<Vec<Body>> {
+ self.mailbox.opportunistic_sync().await?;
+
if *uid {
bail!("UID STORE not implemented");
}
@@ -181,9 +177,11 @@ impl MailboxView {
}
pub async fn expunge(&mut self) -> Result<Vec<Body>> {
+ self.mailbox.opportunistic_sync().await?;
+
let deleted_flag = Flag::Deleted.to_string();
- let msgs = self
- .known_state
+ let state = self.mailbox.current_uid_index().await;
+ let msgs = state
.table
.iter()
.filter(|(_uuid, (_uid, flags))| flags.iter().any(|x| *x == deleted_flag))