refactor!: replace Tantivy search engine with DuckDB

This commit is contained in:
rustmailer
2026-03-03 12:30:26 +08:00
parent ef4ab3496e
commit d2936ed4a7
52 changed files with 3594 additions and 1821 deletions
+18 -22
View File
@@ -20,8 +20,9 @@ use crate::{
decode_mailbox_name, encode_mailbox_name,
modules::{
database::{
async_find_impl, batch_delete_impl, batch_insert_impl, batch_upsert_impl, delete_impl,
filter_by_secondary_key_impl, manager::DB_MANAGER,
async_filter_by_secondary_key_impl, async_find_impl, batch_delete_impl,
batch_insert_impl, batch_upsert_impl, delete_impl, filter_by_secondary_key_impl,
manager::DB_MANAGER,
},
error::{code::ErrorCode, BichonResult},
},
@@ -71,24 +72,6 @@ impl MailBox {
encode_mailbox_name!(&self.name)
}
// pub async fn batch_delete(mailboxes: Vec<MailBox>) -> BichonResult<()> {
// batch_delete_impl(DB_MANAGER.envelope_db(), move |rw| {
// let mut to_deleted = Vec::new();
// for mailbox in mailboxes {
// let retrived = rw
// .get()
// .primary::<MailBox>(mailbox.id)
// .map_err(|e| raise_error!(format!("{:#?}", e), ErrorCode::InternalError))?;
// if let Some(retrived) = retrived {
// to_deleted.push(retrived);
// }
// }
// Ok(to_deleted)
// })
// .await?;
// Ok(())
// }
pub async fn get(id: u64) -> BichonResult<MailBox> {
let result = async_find_impl::<MailBox>(DB_MANAGER.envelope_db(), id).await?;
Ok(result.ok_or_else(|| {
@@ -110,8 +93,21 @@ impl MailBox {
}
pub async fn list_all(account_id: u64) -> BichonResult<Vec<MailBox>> {
filter_by_secondary_key_impl(DB_MANAGER.envelope_db(), MailBoxKey::account_id, account_id)
.await
async_filter_by_secondary_key_impl(
DB_MANAGER.envelope_db(),
MailBoxKey::account_id,
account_id,
)
.await
}
pub fn find_mailbox(account_id: u64, mailbox_id: u64) -> BichonResult<Option<MailBox>> {
let all: Vec<MailBox> = filter_by_secondary_key_impl(
DB_MANAGER.envelope_db(),
MailBoxKey::account_id,
account_id,
)?;
Ok(all.into_iter().find(|m| m.id == mailbox_id))
}
pub async fn batch_insert(mailboxes: &[MailBox]) -> BichonResult<()> {
+1 -1
View File
@@ -62,7 +62,7 @@ pub async fn get_sync_folders(
mailboxes.iter().map(|(m, _)| m.name.clone()).collect(),
)
.await?;
let account = AccountModel::get(account.id).await?;
let account = AccountModel::async_get(account.id).await?;
let subscribed = &account.sync_folders.unwrap_or_default();
let is_noselect = |mailbox: &MailBox| {
mailbox
+1 -1
View File
@@ -54,7 +54,7 @@ impl AccountSyncTask {
let task = move |param: Option<u64>| {
let account_id = param.unwrap();
Box::pin(async move {
let account = AccountModel::get(account_id).await.ok();
let account = AccountModel::async_get(account_id).await.ok();
match account {
Some(account) => {
if !account.enabled {