|
@@ -154,18 +154,16 @@ fn retrieve_and_save_attachments(parsed_mail: ParsedMail, list: String, file_nam
|
|
|
|
|
|
/// saves email to local file system
|
|
|
fn persist_email(msg: &Message, uid: u32, list: String, original_path: PathBuf) -> anyhow::Result<()>{
|
|
|
+ let mut indexes = Indexes::new();
|
|
|
+
|
|
|
// creating all folders
|
|
|
if Config::global().out_dir.exists() {
|
|
|
std::fs::create_dir_all(&Config::global().out_dir).ok();
|
|
|
}
|
|
|
let message_dir = Config::global().out_dir.join(list.clone()).join("messages");
|
|
|
- let message_xml_dir = Config::global().out_dir.join(list.clone()).join("messages_xml");
|
|
|
if !message_dir.exists() {
|
|
|
std::fs::create_dir_all(&message_dir).ok();
|
|
|
}
|
|
|
- if !message_xml_dir.exists() {
|
|
|
- std::fs::create_dir_all(&message_xml_dir).ok();
|
|
|
- }
|
|
|
|
|
|
// persist email
|
|
|
let mut message = StrMessage::new(msg, uid, list.clone());
|
|
@@ -186,13 +184,17 @@ fn persist_email(msg: &Message, uid: u32, list: String, original_path: PathBuf)
|
|
|
}
|
|
|
|
|
|
// ingest text from the message to the sonic server // TODO create as queue if server is not accessible
|
|
|
- let mut ingest_channel = IngestSonic::new()?;
|
|
|
- let data = message.to_ingest();
|
|
|
- match ingest_channel.ingest_document("emails", &*list, &*message.hash.clone(), &*data) { // TODO change message.hash to id
|
|
|
- Ok(_) => {}
|
|
|
- Err(_) => {println!("Unable to ingest {} email to sonic search", message.hash.clone())}
|
|
|
+ match IngestSonic::new(){
|
|
|
+ Ok(mut ingest_channel) => {
|
|
|
+ let data = message.to_ingest();
|
|
|
+ match ingest_channel.ingest_document("emails", &*list, &*message.hash.clone(), &*data) { // TODO change message.hash to id
|
|
|
+ Ok(_) => {}
|
|
|
+ Err(_) => {println!("Unable to ingest {} email to sonic search", message.hash.clone())}
|
|
|
+ };
|
|
|
+ let _ = ingest_channel.stop_ingest();
|
|
|
+ }
|
|
|
+ Err(_) => {}
|
|
|
};
|
|
|
- let _ = ingest_channel.stop_ingest();
|
|
|
|
|
|
|
|
|
// indexing
|