accounts: auto re-index sqlite3 database if it's missing
Instead of telling user to do it themselvespull/223/head
parent
e0257c9d8d
commit
d7e6b40b7e
|
@ -146,3 +146,38 @@ impl Action {
|
|||
type AccountName = String;
|
||||
type MailboxPath = String;
|
||||
type NewMailboxPath = String;
|
||||
|
||||
macro_rules! impl_into_action {
|
||||
($({$t:ty => $var:tt}),*) => {
|
||||
$(
|
||||
impl From<$t> for Action {
|
||||
fn from(v: $t) -> Self {
|
||||
Self::$var(v)
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
macro_rules! impl_tuple_into_action {
|
||||
($({$a:ty,$b:ty => $var:tt}),*) => {
|
||||
$(
|
||||
impl From<($a,$b)> for Action {
|
||||
fn from((a, b): ($a,$b)) -> Self {
|
||||
Self::$var(a, b)
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
impl_into_action!(
|
||||
{ ListingAction => Listing },
|
||||
{ TabAction => Tab },
|
||||
{ MailingListAction => MailingListAction },
|
||||
{ ViewAction => View },
|
||||
{ ComposeAction => Compose }
|
||||
);
|
||||
impl_tuple_into_action!(
|
||||
{ AccountName, MailboxOperation => Mailbox },
|
||||
{ AccountName, AccountAction => AccountAction }
|
||||
);
|
||||
|
|
|
@ -56,6 +56,7 @@ use smallvec::SmallVec;
|
|||
|
||||
use super::{AccountConf, FileMailboxConf};
|
||||
use crate::{
|
||||
command::actions::AccountAction,
|
||||
jobs::{JobExecutor, JobId, JoinHandle},
|
||||
types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification},
|
||||
StatusEvent, ThreadEvent,
|
||||
|
@ -523,13 +524,14 @@ impl Account {
|
|||
};
|
||||
if let Some(db_path) = db_path {
|
||||
if !db_path.exists() {
|
||||
log::info!(
|
||||
"An sqlite3 search database for account `{}` seems to be missing, a new \
|
||||
one will be created.",
|
||||
name
|
||||
);
|
||||
sender
|
||||
.send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
|
||||
StatusEvent::DisplayMessage(format!(
|
||||
"An sqlite3 search database for account `{}` seems to be missing, \
|
||||
a new one must be created with the `reindex` command.",
|
||||
name
|
||||
)),
|
||||
.send(ThreadEvent::UIEvent(UIEvent::Action(
|
||||
(name.clone(), AccountAction::ReIndex).into(),
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue