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