melib/notmuch: don't read messages to String
parent
79b2b38e32
commit
92a9127758
|
@ -352,7 +352,7 @@ impl MailBackend for NotmuchDb {
|
||||||
}
|
}
|
||||||
let database = Arc::new(database.unwrap());
|
let database = Arc::new(database.unwrap());
|
||||||
let database_lck = database.inner.read().unwrap();
|
let database_lck = database.inner.read().unwrap();
|
||||||
let mut mailboxes_lck = mailboxes.read().unwrap();
|
let mailboxes_lck = mailboxes.read().unwrap();
|
||||||
let mailbox = mailboxes_lck.get(&mailbox_hash).unwrap();
|
let mailbox = mailboxes_lck.get(&mailbox_hash).unwrap();
|
||||||
let mut unseen_count = 0;
|
let mut unseen_count = 0;
|
||||||
let query: Query =
|
let query: Query =
|
||||||
|
@ -401,7 +401,13 @@ impl MailBackend for NotmuchDb {
|
||||||
ret.push(env);
|
ret.push(env);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
debug!("could not parse message {:?}", err);
|
debug!("could not parse message {:?} {}", err, {
|
||||||
|
let fs_path = unsafe {
|
||||||
|
call!(lib, notmuch_message_get_filename)(message)
|
||||||
|
};
|
||||||
|
let c_str = unsafe { CStr::from_ptr(fs_path) };
|
||||||
|
String::from_utf8_lossy(c_str.to_bytes())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,7 +799,7 @@ struct NotmuchOp {
|
||||||
index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
|
index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
|
||||||
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
|
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
|
||||||
database: Arc<DbConnection>,
|
database: Arc<DbConnection>,
|
||||||
bytes: Option<String>,
|
bytes: Option<Vec<u8>>,
|
||||||
lib: Arc<libloading::Library>,
|
lib: Arc<libloading::Library>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,10 +817,10 @@ impl BackendOp for NotmuchOp {
|
||||||
let fs_path = unsafe { call!(self.lib, notmuch_message_get_filename)(message) };
|
let fs_path = unsafe { call!(self.lib, notmuch_message_get_filename)(message) };
|
||||||
let c_str = unsafe { CStr::from_ptr(fs_path) };
|
let c_str = unsafe { CStr::from_ptr(fs_path) };
|
||||||
let mut f = std::fs::File::open(&OsStr::from_bytes(c_str.to_bytes()))?;
|
let mut f = std::fs::File::open(&OsStr::from_bytes(c_str.to_bytes()))?;
|
||||||
let mut response = String::new();
|
let mut response = Vec::new();
|
||||||
f.read_to_string(&mut response)?;
|
f.read_to_end(&mut response)?;
|
||||||
self.bytes = Some(response);
|
self.bytes = Some(response);
|
||||||
let ret = Ok(self.bytes.as_ref().unwrap().as_bytes().to_vec());
|
let ret = Ok(self.bytes.as_ref().unwrap().to_vec());
|
||||||
Ok(Box::pin(async move { ret }))
|
Ok(Box::pin(async move { ret }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,11 +1033,11 @@ fn notmuch_message_into_envelope(
|
||||||
database: Arc<DbConnection>,
|
database: Arc<DbConnection>,
|
||||||
message: *mut notmuch_message_t,
|
message: *mut notmuch_message_t,
|
||||||
) -> Result<Envelope> {
|
) -> Result<Envelope> {
|
||||||
let mut response = String::new();
|
let mut response = Vec::new();
|
||||||
let fs_path = unsafe { call!(lib, notmuch_message_get_filename)(message) };
|
let fs_path = unsafe { call!(lib, notmuch_message_get_filename)(message) };
|
||||||
let c_str = unsafe { CStr::from_ptr(fs_path) };
|
let c_str = unsafe { CStr::from_ptr(fs_path) };
|
||||||
let mut f = std::fs::File::open(&OsStr::from_bytes(c_str.to_bytes()))?;
|
let mut f = std::fs::File::open(&OsStr::from_bytes(c_str.to_bytes()))?;
|
||||||
f.read_to_string(&mut response)?;
|
f.read_to_end(&mut response)?;
|
||||||
let msg_id = unsafe { call!(lib, notmuch_message_get_message_id)(message) };
|
let msg_id = unsafe { call!(lib, notmuch_message_get_message_id)(message) };
|
||||||
let env_hash = {
|
let env_hash = {
|
||||||
let c_str = unsafe { CStr::from_ptr(msg_id) };
|
let c_str = unsafe { CStr::from_ptr(msg_id) };
|
||||||
|
|
Loading…
Reference in New Issue