summaryrefslogtreecommitdiff
path: root/melib/src/backends/imap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'melib/src/backends/imap.rs')
-rw-r--r--melib/src/backends/imap.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs
index 0cb1550f..88be46dd 100644
--- a/melib/src/backends/imap.rs
+++ b/melib/src/backends/imap.rs
@@ -33,7 +33,7 @@ pub use connection::*;
mod watch;
pub use watch::*;
mod cache;
-use cache::ModSequence;
+use cache::{ImapCacheReset, ModSequence};
pub mod managesieve;
mod untagged;
@@ -301,14 +301,26 @@ impl MailBackend for ImapType {
if self.uid_store.keep_offline_cache {
match cache::Sqlite3Cache::get(self.uid_store.clone()).chain_err_summary(|| {
format!(
- "Could not initialize cache for IMAP account {}",
+ "Could not initialize cache for IMAP account {}. Resetting database.",
self.uid_store.account_name
)
}) {
Ok(v) => Some(v),
Err(err) => {
(self.uid_store.event_consumer)(self.uid_store.account_hash, err.into());
- None
+ match cache::Sqlite3Cache::reset_db(&self.uid_store)
+ .and_then(|()| cache::Sqlite3Cache::get(self.uid_store.clone()))
+ .chain_err_summary(|| "Could not reset IMAP cache database.")
+ {
+ Ok(v) => Some(v),
+ Err(err) => {
+ (self.uid_store.event_consumer)(
+ self.uid_store.account_hash,
+ err.into(),
+ );
+ None
+ }
+ }
}
}
} else {