aboutsummaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-10 17:07:07 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-10 17:07:07 +0100
commit9cec7803d28617f1bfd1ac1621c2eda9582201d4 (patch)
tree46734d3ae0029f4c725df53d383cf918ccb82a04 /src/mail
parent96332c9bfe6a9f01e3fdb0b2b565ad669fb526b1 (diff)
downloadaerogramme-9cec7803d28617f1bfd1ac1621c2eda9582201d4.tar.gz
aerogramme-9cec7803d28617f1bfd1ac1621c2eda9582201d4.zip
Implement HIGHESTMODSEQ for STATUS
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/mailbox.rs3
-rw-r--r--src/mail/query.rs7
-rw-r--r--src/mail/uidindex.rs24
3 files changed, 15 insertions, 19 deletions
diff --git a/src/mail/mailbox.rs b/src/mail/mailbox.rs
index 84fa5af..5e95f32 100644
--- a/src/mail/mailbox.rs
+++ b/src/mail/mailbox.rs
@@ -465,6 +465,9 @@ impl MailboxInternal {
}
}
+// Can be useful to debug so we want this code
+// to be available to developers
+#[allow(dead_code)]
fn dump(uid_index: &Bayou<UidIndex>) {
let s = uid_index.state();
println!("---- MAILBOX STATE ----");
diff --git a/src/mail/query.rs b/src/mail/query.rs
index 0838800..a183c5a 100644
--- a/src/mail/query.rs
+++ b/src/mail/query.rs
@@ -125,13 +125,6 @@ impl QueryResult {
}
}
- fn into_partial(self, metadata: MailMeta) -> Option<Self> {
- match self {
- Self::IndexResult { uuid } => Some(Self::PartialResult { uuid, metadata }),
- _ => None,
- }
- }
-
fn into_full(self, content: Vec<u8>) -> Option<Self> {
match self {
Self::PartialResult { uuid, metadata } => Some(Self::FullResult {
diff --git a/src/mail/uidindex.rs b/src/mail/uidindex.rs
index e7023cf..f703d04 100644
--- a/src/mail/uidindex.rs
+++ b/src/mail/uidindex.rs
@@ -1,4 +1,4 @@
-use std::num::NonZeroU32;
+use std::num::{NonZeroU32, NonZeroU64};
use im::{HashMap, OrdMap, OrdSet};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::bayou::*;
use crate::mail::unique_ident::UniqueIdent;
-pub type ModSeq = NonZeroU32;
+pub type ModSeq = NonZeroU64;
pub type ImapUid = NonZeroU32;
pub type ImapUidvalidity = NonZeroU32;
pub type Flag = String;
@@ -118,10 +118,10 @@ impl Default for UidIndex {
uidvalidity: NonZeroU32::new(1).unwrap(),
uidnext: NonZeroU32::new(1).unwrap(),
- highestmodseq: NonZeroU32::new(1).unwrap(),
+ highestmodseq: NonZeroU64::new(1).unwrap(),
internalseq: NonZeroU32::new(1).unwrap(),
- internalmodseq: NonZeroU32::new(1).unwrap(),
+ internalmodseq: NonZeroU64::new(1).unwrap(),
}
}
}
@@ -138,7 +138,7 @@ impl BayouState for UidIndex {
// The intuition: we increase the UIDValidity by the number of possible conflicts
if *uid < new.internalseq || *modseq < new.internalmodseq {
let bump_uid = new.internalseq.get() - uid.get();
- let bump_modseq = new.internalmodseq.get() - modseq.get();
+ let bump_modseq = (new.internalmodseq.get() - modseq.get()) as u32;
new.uidvalidity =
NonZeroU32::new(new.uidvalidity.get() + bump_uid + bump_modseq)
.unwrap();
@@ -164,7 +164,7 @@ impl BayouState for UidIndex {
new.highestmodseq = new.internalmodseq;
new.internalseq = NonZeroU32::new(new.internalseq.get() + 1).unwrap();
- new.internalmodseq = NonZeroU32::new(new.internalmodseq.get() + 1).unwrap();
+ new.internalmodseq = NonZeroU64::new(new.internalmodseq.get() + 1).unwrap();
new.uidnext = new.internalseq;
}
@@ -179,7 +179,7 @@ impl BayouState for UidIndex {
if let Some((uid, email_modseq, existing_flags)) = new.table.get_mut(ident) {
// Bump UIDValidity if required
if *candidate_modseq < new.internalmodseq {
- let bump_modseq = new.internalmodseq.get() - candidate_modseq.get();
+ let bump_modseq = (new.internalmodseq.get() - candidate_modseq.get()) as u32;
new.uidvalidity =
NonZeroU32::new(new.uidvalidity.get() + bump_modseq)
.unwrap();
@@ -198,14 +198,14 @@ impl BayouState for UidIndex {
// Update counters
new.highestmodseq = new.internalmodseq;
- new.internalmodseq = NonZeroU32::new(new.internalmodseq.get() + 1).unwrap();
+ new.internalmodseq = NonZeroU64::new(new.internalmodseq.get() + 1).unwrap();
}
}
UidIndexOp::FlagDel(ident, candidate_modseq, rm_flags) => {
if let Some((uid, email_modseq, existing_flags)) = new.table.get_mut(ident) {
// Bump UIDValidity if required
if *candidate_modseq < new.internalmodseq {
- let bump_modseq = new.internalmodseq.get() - candidate_modseq.get();
+ let bump_modseq = (new.internalmodseq.get() - candidate_modseq.get()) as u32;
new.uidvalidity =
NonZeroU32::new(new.uidvalidity.get() + bump_modseq)
.unwrap();
@@ -221,14 +221,14 @@ impl BayouState for UidIndex {
// Update counters
new.highestmodseq = new.internalmodseq;
- new.internalmodseq = NonZeroU32::new(new.internalmodseq.get() + 1).unwrap();
+ new.internalmodseq = NonZeroU64::new(new.internalmodseq.get() + 1).unwrap();
}
}
UidIndexOp::FlagSet(ident, candidate_modseq, new_flags) => {
if let Some((uid, email_modseq, existing_flags)) = new.table.get_mut(ident) {
// Bump UIDValidity if required
if *candidate_modseq < new.internalmodseq {
- let bump_modseq = new.internalmodseq.get() - candidate_modseq.get();
+ let bump_modseq = (new.internalmodseq.get() - candidate_modseq.get()) as u32;
new.uidvalidity =
NonZeroU32::new(new.uidvalidity.get() + bump_modseq)
.unwrap();
@@ -255,7 +255,7 @@ impl BayouState for UidIndex {
// Update counters
new.highestmodseq = new.internalmodseq;
- new.internalmodseq = NonZeroU32::new(new.internalmodseq.get() + 1).unwrap();
+ new.internalmodseq = NonZeroU64::new(new.internalmodseq.get() + 1).unwrap();
}
}
UidIndexOp::BumpUidvalidity(count) => {