Skip to content

Commit c5494e7

Browse files
committed
Delete imap and imap_sync rows when the transport is deleted
1 parent 18d3f37 commit c5494e7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/configure.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,20 @@ impl Context {
220220
if current_addr == addr {
221221
bail!("Cannot delete current transport");
222222
}
223-
transaction.execute("DELETE FROM transports WHERE addr=?", (addr,))?;
223+
let transport_id = transaction.query_row(
224+
"DELETE FROM transports WHERE addr=? RETURNING id",
225+
(addr,),
226+
|row| {
227+
let id: u32 = row.get(0)?;
228+
Ok(id)
229+
},
230+
)?;
231+
transaction.execute("DELETE FROM imap WHERE transport_id=?", (transport_id,))?;
232+
transaction.execute(
233+
"DELETE FROM imap_sync WHERE transport_id=?",
234+
(transport_id,),
235+
)?;
236+
224237
Ok(())
225238
})
226239
.await?;

0 commit comments

Comments
 (0)