v0.2.0
This commit is contained in:
1 parent
fc81ecafd6
commit
dc57aa7089
89 files changed
+5290
-1551
No files matched your search
@@ -224,8 +224,11 @@ pub async fn empty_folder(
|
||||
|
||||
let conn = db::pool::open_user_db(&config.data_dir, &session.user_hash)
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
let transaction = conn
|
||||
.unchecked_transaction()
|
||||
.map_err(|e| AppError::InternalError(format!("Database transaction error: {e}")))?;
|
||||
let uids: Vec<u32> = {
|
||||
let mut statement = conn
|
||||
let mut statement = transaction
|
||||
.prepare(crate::dbq!(routes_folder_mgmt::Q_003))
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
let rows = statement
|
||||
@@ -233,18 +236,22 @@ pub async fn empty_folder(
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
rows.filter_map(Result::ok).collect()
|
||||
};
|
||||
db::messages::delete_folder_messages(&conn, &name)
|
||||
db::messages::delete_folder_messages(&transaction, &name)
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
conn.execute(crate::dbq!(routes_folder_mgmt::Q_004), [&name])
|
||||
transaction
|
||||
.execute(crate::dbq!(routes_folder_mgmt::Q_004), [&name])
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
|
||||
if let Ok(index) = search_engine.open_user_index(&session.user_hash) {
|
||||
for uid in uids {
|
||||
if let Err(error) = index.delete_message(uid, &name) {
|
||||
tracing::warn!(uid, folder = %name, %error, "Failed to remove emptied message from search index");
|
||||
}
|
||||
index
|
||||
.delete_message_with_connection(&transaction, uid, &name)
|
||||
.map_err(|e| AppError::InternalError(format!("Search outbox error: {e}")))?;
|
||||
}
|
||||
}
|
||||
transaction
|
||||
.commit()
|
||||
.map_err(|e| AppError::InternalError(format!("Database commit error: {e}")))?;
|
||||
|
||||
Ok(Json(MessageResponse { status: "emptied" }).into_response())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user