Skip to content

Commit a910808

Browse files
committed
feat: delete_msgs: Use transaction() instead of call_write()
Explicit transaction does the only commit (and fsync()).
1 parent 3d5e442 commit a910808

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/location.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,6 @@ pub(crate) async fn save(
707707
))?;
708708

709709
if timestamp > newest_timestamp {
710-
// okay to drop, as we use cached prepared statements
711-
drop(stmt_test);
712-
drop(stmt_insert);
713710
newest_timestamp = timestamp;
714711
newest_location_id = Some(u32::try_from(conn.last_insert_rowid())?);
715712
}

src/message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,15 +1613,15 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
16131613
modified_chat_ids.insert(msg.chat_id);
16141614

16151615
let target = context.get_delete_msgs_target().await?;
1616-
let update_db = |conn: &mut rusqlite::Connection| {
1617-
conn.execute(
1616+
let update_db = |trans: &mut rusqlite::Transaction| {
1617+
trans.execute(
16181618
"UPDATE imap SET target=? WHERE rfc724_mid=?",
16191619
(target, msg.rfc724_mid),
16201620
)?;
1621-
conn.execute("DELETE FROM smtp WHERE msg_id=?", (msg_id,))?;
1621+
trans.execute("DELETE FROM smtp WHERE msg_id=?", (msg_id,))?;
16221622
Ok(())
16231623
};
1624-
if let Err(e) = context.sql.call_write(update_db).await {
1624+
if let Err(e) = context.sql.transaction(update_db).await {
16251625
error!(context, "delete_msgs: failed to update db: {e:#}.");
16261626
res = Err(e);
16271627
continue;

0 commit comments

Comments
 (0)