Resultify MsgId.delete_from_db()

This commit is contained in:
Alexander Krotov
2020-02-25 22:47:59 +03:00
parent bc06b9e051
commit f2aa17c9d0
3 changed files with 6 additions and 10 deletions

View File

@@ -286,10 +286,7 @@ impl ChatId {
/// Returns `true`, if message was deleted, `false` otherwise.
fn maybe_delete_draft(self, context: &Context) -> bool {
match self.get_draft_msg_id(context) {
Some(msg_id) => {
msg_id.delete_from_db(context);
true
}
Some(msg_id) => msg_id.delete_from_db(context).is_ok(),
None => false,
}
}

View File

@@ -487,7 +487,7 @@ impl Job {
// Hidden messages are similar to trashed, but are
// related to some chat. We also delete their
// database records.
msg.id.delete_from_db(context);
job_try!(msg.id.delete_from_db(context))
} else {
// Remove server UID from the database record.
//

View File

@@ -100,7 +100,7 @@ impl MsgId {
}
/// Deletes a message and corresponding MDNs from the database.
pub fn delete_from_db(self, context: &Context) {
pub fn delete_from_db(self, context: &Context) -> crate::sql::Result<()> {
// We don't use transactions yet, so remove MDNs first to make
// sure they are not left while the message is deleted.
sql::execute(
@@ -108,15 +108,14 @@ impl MsgId {
&context.sql,
"DELETE FROM msgs_mdns WHERE msg_id=?;",
params![self],
)
.ok();
)?;
sql::execute(
context,
&context.sql,
"DELETE FROM msgs WHERE id=?;",
params![self],
)
.ok();
)?;
Ok(())
}
/// Removes IMAP server UID and folder from the database record.