parent
55948dd7c2
commit
2d3f49d64d
|
@ -126,7 +126,7 @@ pub struct UIDStore {
|
||||||
cache_headers: bool,
|
cache_headers: bool,
|
||||||
uidvalidity: Arc<Mutex<HashMap<MailboxHash, UID>>>,
|
uidvalidity: Arc<Mutex<HashMap<MailboxHash, UID>>>,
|
||||||
hash_index: Arc<Mutex<HashMap<EnvelopeHash, (UID, MailboxHash)>>>,
|
hash_index: Arc<Mutex<HashMap<EnvelopeHash, (UID, MailboxHash)>>>,
|
||||||
uid_index: Arc<Mutex<HashMap<UID, EnvelopeHash>>>,
|
uid_index: Arc<Mutex<HashMap<(MailboxHash, UID), EnvelopeHash>>>,
|
||||||
|
|
||||||
byte_cache: Arc<Mutex<HashMap<UID, EnvelopeCache>>>,
|
byte_cache: Arc<Mutex<HashMap<UID, EnvelopeCache>>>,
|
||||||
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
|
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
|
||||||
|
@ -264,7 +264,11 @@ impl MailBackend for ImapType {
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(env.hash(), (uid, mailbox_hash));
|
.insert(env.hash(), (uid, mailbox_hash));
|
||||||
uid_store.uid_index.lock().unwrap().insert(uid, env.hash());
|
uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
payload.push(env);
|
payload.push(env);
|
||||||
}
|
}
|
||||||
debug!("sending cached payload for {}", mailbox_hash);
|
debug!("sending cached payload for {}", mailbox_hash);
|
||||||
|
@ -378,7 +382,11 @@ impl MailBackend for ImapType {
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(env.hash(), (uid, mailbox_hash));
|
.insert(env.hash(), (uid, mailbox_hash));
|
||||||
uid_store.uid_index.lock().unwrap().insert(uid, env.hash());
|
uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
envelopes.push((uid, env));
|
envelopes.push((uid, env));
|
||||||
}
|
}
|
||||||
exists =
|
exists =
|
||||||
|
@ -924,7 +932,7 @@ impl MailBackend for ImapType {
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.map(usize::from_str)
|
.map(usize::from_str)
|
||||||
.filter_map(std::result::Result::ok)
|
.filter_map(std::result::Result::ok)
|
||||||
.filter_map(|uid| uid_index.get(&uid))
|
.filter_map(|uid| uid_index.get(&(mailbox_hash, uid)))
|
||||||
.map(|env_hash_ref| *env_hash_ref),
|
.map(|env_hash_ref| *env_hash_ref),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,13 @@ impl ImapConnection {
|
||||||
uid, flags, body, ..
|
uid, flags, body, ..
|
||||||
} in v
|
} in v
|
||||||
{
|
{
|
||||||
if self.uid_store.uid_index.lock().unwrap().contains_key(&uid) {
|
if self
|
||||||
|
.uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
continue 'fetch_responses;
|
continue 'fetch_responses;
|
||||||
}
|
}
|
||||||
if let Ok(mut env) = Envelope::from_bytes(
|
if let Ok(mut env) = Envelope::from_bytes(
|
||||||
|
@ -116,7 +122,7 @@ impl ImapConnection {
|
||||||
.uid_index
|
.uid_index
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(uid, env.hash());
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
if let Some((_, keywords)) = flags {
|
if let Some((_, keywords)) = flags {
|
||||||
let mut tag_lck = self.uid_store.tag_index.write().unwrap();
|
let mut tag_lck = self.uid_store.tag_index.write().unwrap();
|
||||||
for f in keywords {
|
for f in keywords {
|
||||||
|
@ -185,7 +191,12 @@ impl ImapConnection {
|
||||||
} in v
|
} in v
|
||||||
{
|
{
|
||||||
*mailbox.exists.lock().unwrap() += 1;
|
*mailbox.exists.lock().unwrap() += 1;
|
||||||
if !self.uid_store.uid_index.lock().unwrap().contains_key(&uid)
|
if !self
|
||||||
|
.uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
{
|
{
|
||||||
if let Ok(mut env) = Envelope::from_bytes(
|
if let Ok(mut env) = Envelope::from_bytes(
|
||||||
body.unwrap(),
|
body.unwrap(),
|
||||||
|
@ -200,7 +211,7 @@ impl ImapConnection {
|
||||||
.uid_index
|
.uid_index
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(uid, env.hash());
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
debug!(
|
debug!(
|
||||||
"Create event {} {} {}",
|
"Create event {} {} {}",
|
||||||
env.hash(),
|
env.hash(),
|
||||||
|
@ -271,8 +282,12 @@ impl ImapConnection {
|
||||||
{
|
{
|
||||||
Ok(mut v) => {
|
Ok(mut v) => {
|
||||||
if let Some(uid) = v.pop() {
|
if let Some(uid) = v.pop() {
|
||||||
if let Some(env_hash) =
|
if let Some(env_hash) = self
|
||||||
self.uid_store.uid_index.lock().unwrap().get(&uid)
|
.uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.get(&(mailbox_hash, uid))
|
||||||
{
|
{
|
||||||
self.uid_store
|
self.uid_store
|
||||||
.refresh_events
|
.refresh_events
|
||||||
|
|
|
@ -331,7 +331,12 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctr += 1;
|
ctr += 1;
|
||||||
*mailbox.exists.lock().unwrap() += 1;
|
*mailbox.exists.lock().unwrap() += 1;
|
||||||
if !uid_store.uid_index.lock().unwrap().contains_key(&uid) {
|
if !uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
if let Ok(mut env) = Envelope::from_bytes(
|
if let Ok(mut env) = Envelope::from_bytes(
|
||||||
body.unwrap(),
|
body.unwrap(),
|
||||||
flags.as_ref().map(|&(f, _)| f),
|
flags.as_ref().map(|&(f, _)| f),
|
||||||
|
@ -345,7 +350,7 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
|
||||||
.uid_index
|
.uid_index
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(uid, env.hash());
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
debug!(
|
debug!(
|
||||||
"Create event {} {} {}",
|
"Create event {} {} {}",
|
||||||
env.hash(),
|
env.hash(),
|
||||||
|
@ -460,7 +465,12 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
|
||||||
format!("parsing {}/{} envelopes..", ctr, len),
|
format!("parsing {}/{} envelopes..", ctr, len),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if uid_store.uid_index.lock().unwrap().contains_key(&uid) {
|
if uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
ctr += 1;
|
ctr += 1;
|
||||||
continue 'fetch_responses_b;
|
continue 'fetch_responses_b;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +484,11 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(env.hash(), (uid, mailbox_hash));
|
.insert(env.hash(), (uid, mailbox_hash));
|
||||||
uid_store.uid_index.lock().unwrap().insert(uid, env.hash());
|
uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
if let Some((_, keywords)) = flags {
|
if let Some((_, keywords)) = flags {
|
||||||
let mut tag_lck = uid_store.tag_index.write().unwrap();
|
let mut tag_lck = uid_store.tag_index.write().unwrap();
|
||||||
for f in keywords {
|
for f in keywords {
|
||||||
|
@ -552,7 +566,12 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
|
||||||
{
|
{
|
||||||
Ok(mut v) => {
|
Ok(mut v) => {
|
||||||
if let Some(uid) = v.pop() {
|
if let Some(uid) = v.pop() {
|
||||||
if let Some(env_hash) = uid_store.uid_index.lock().unwrap().get(&uid) {
|
if let Some(env_hash) = uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.get(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
conn.add_refresh_event(RefreshEvent {
|
conn.add_refresh_event(RefreshEvent {
|
||||||
account_hash,
|
account_hash,
|
||||||
mailbox_hash,
|
mailbox_hash,
|
||||||
|
@ -696,7 +715,12 @@ pub fn examine_updates(
|
||||||
..
|
..
|
||||||
} in v
|
} in v
|
||||||
{
|
{
|
||||||
if uid_store.uid_index.lock().unwrap().contains_key(&uid) {
|
if uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
continue 'fetch_responses_c;
|
continue 'fetch_responses_c;
|
||||||
}
|
}
|
||||||
if let Ok(mut env) = Envelope::from_bytes(
|
if let Ok(mut env) = Envelope::from_bytes(
|
||||||
|
@ -712,7 +736,7 @@ pub fn examine_updates(
|
||||||
.uid_index
|
.uid_index
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(uid, env.hash());
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
debug!(
|
debug!(
|
||||||
"Create event {} {} {}",
|
"Create event {} {} {}",
|
||||||
env.hash(),
|
env.hash(),
|
||||||
|
@ -790,7 +814,12 @@ pub fn examine_updates(
|
||||||
uid, flags, body, ..
|
uid, flags, body, ..
|
||||||
} in v
|
} in v
|
||||||
{
|
{
|
||||||
if uid_store.uid_index.lock().unwrap().contains_key(&uid) {
|
if uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.contains_key(&(mailbox_hash, uid))
|
||||||
|
{
|
||||||
continue 'fetch_responses_a;
|
continue 'fetch_responses_a;
|
||||||
}
|
}
|
||||||
if let Ok(mut env) =
|
if let Ok(mut env) =
|
||||||
|
@ -801,7 +830,11 @@ pub fn examine_updates(
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(env.hash(), (uid, mailbox_hash));
|
.insert(env.hash(), (uid, mailbox_hash));
|
||||||
uid_store.uid_index.lock().unwrap().insert(uid, env.hash());
|
uid_store
|
||||||
|
.uid_index
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.insert((mailbox_hash, uid), env.hash());
|
||||||
if let Some((_, keywords)) = flags {
|
if let Some((_, keywords)) = flags {
|
||||||
let mut tag_lck = uid_store.tag_index.write().unwrap();
|
let mut tag_lck = uid_store.tag_index.write().unwrap();
|
||||||
for f in keywords {
|
for f in keywords {
|
||||||
|
|
Loading…
Reference in New Issue