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. /// Returns `true`, if message was deleted, `false` otherwise.
fn maybe_delete_draft(self, context: &Context) -> bool { fn maybe_delete_draft(self, context: &Context) -> bool {
match self.get_draft_msg_id(context) { match self.get_draft_msg_id(context) {
Some(msg_id) => { Some(msg_id) => msg_id.delete_from_db(context).is_ok(),
msg_id.delete_from_db(context);
true
}
None => false, None => false,
} }
} }

View File

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

View File

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