Add reindex command
parent
78eecbb104
commit
0a606a71d1
|
@ -23,6 +23,7 @@ use melib::backends::{FolderHash, MailBackend};
|
|||
use melib::email::{EnvelopeHash, Flag, UnixTimestamp};
|
||||
use melib::mailbox::*;
|
||||
use melib::thread::{ThreadHash, ThreadNode};
|
||||
use std::sync::RwLock;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Query {
|
||||
|
@ -56,6 +57,7 @@ pub struct Cache {
|
|||
kind: CacheType,
|
||||
backend: Box<dyn MailBackend>,
|
||||
}
|
||||
/*
|
||||
|
||||
impl Cache {
|
||||
pub fn build_index(&mut self) {
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use fnv::FnvHashMap;
|
||||
use melib::{
|
||||
email::EnvelopeHash,
|
||||
email::{Envelope, EnvelopeHash},
|
||||
thread::{SortField, SortOrder},
|
||||
MeliError, Result, StackVec,
|
||||
};
|
||||
use rusqlite::{params, Connection};
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[inline(always)]
|
||||
fn escape_double_quote(w: &str) -> Cow<str> {
|
||||
|
@ -160,7 +162,7 @@ END; ",
|
|||
Ok(conn)
|
||||
}
|
||||
|
||||
pub fn insert(context: &crate::state::Context) -> Result<()> {
|
||||
pub fn insert(context: &mut crate::state::Context) -> Result<()> {
|
||||
let data_dir =
|
||||
xdg::BaseDirectories::with_prefix("meli").map_err(|e| MeliError::new(e.to_string()))?;
|
||||
let conn = Connection::open(
|
||||
|
|
|
@ -530,7 +530,6 @@ impl State {
|
|||
/// Convert user commands to actions/method calls.
|
||||
fn parse_command(&mut self, cmd: &str) {
|
||||
if cmd == "insert" {
|
||||
crate::sqlite3::insert(&self.context).unwrap();
|
||||
return;
|
||||
} else if cmd.starts_with("_from") {
|
||||
debug!(crate::sqlite3::from(&cmd["_from".len()..]));
|
||||
|
@ -572,6 +571,22 @@ impl State {
|
|||
));
|
||||
}
|
||||
}
|
||||
AccountAction(_, ReIndex) => match crate::sqlite3::insert(&mut self.context) {
|
||||
Ok(()) => {
|
||||
self.context.replies.push_back(UIEvent::Notification(
|
||||
None,
|
||||
"Message index rebuild started.".to_string(),
|
||||
Some(NotificationType::INFO),
|
||||
));
|
||||
}
|
||||
Err(e) => {
|
||||
self.context.replies.push_back(UIEvent::Notification(
|
||||
None,
|
||||
format!("Message index rebuild failed: {}.", e),
|
||||
Some(NotificationType::ERROR),
|
||||
));
|
||||
}
|
||||
},
|
||||
v => {
|
||||
self.rcv_event(UIEvent::Action(v));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue