aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-12-03 22:28:57 -0400
committerDavid Bremner <david@tethera.net>2022-12-27 11:59:46 -0400
commit1d5d0ae68689e7b1d6b974e275f19371250c4b25 (patch)
tree664ff033c279c517793e32b185b13bdcc9b5df95 /lib
parent966f40086f36a5bf26d8c180cd34a01636971a84 (diff)
lib/message: move xapian call inside try/catch block in _n_m_delete
The call to delete_document can throw exceptions (and can happen in practice [1]), so catch the exception and extract the error message. As a side effect, also move the call to _n_m_has_term inside the try/catch. This should not change anything as that function already traps any Xapian exceptions. [1]: id:wwuk039sk2p.fsf@chaotikum.eu
Diffstat (limited to 'lib')
-rw-r--r--lib/message.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/message.cc b/lib/message.cc
index 1c87f8c0..5ccca95a 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1383,21 +1383,21 @@ _notmuch_message_delete (notmuch_message_t *message)
if (status)
return status;
- message->notmuch->writable_xapian_db->delete_document (message->doc_id);
-
- /* if this was a ghost to begin with, we are done */
- private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
- if (private_status)
- return COERCE_STATUS (private_status,
- "Error trying to determine whether message was a ghost");
- if (is_ghost)
- return NOTMUCH_STATUS_SUCCESS;
-
- /* look for a non-ghost message in the same thread */
try {
Xapian::PostingIterator thread_doc, thread_doc_end;
Xapian::PostingIterator mail_doc, mail_doc_end;
+ message->notmuch->writable_xapian_db->delete_document (message->doc_id);
+
+ /* look for a non-ghost message in the same thread */
+ /* if this was a ghost to begin with, we are done */
+ private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
+ if (private_status)
+ return COERCE_STATUS (private_status,
+ "Error trying to determine whether message was a ghost");
+ if (is_ghost)
+ return NOTMUCH_STATUS_SUCCESS;
+
_notmuch_database_find_doc_ids (message->notmuch, "thread", tid, &thread_doc,
&thread_doc_end);
_notmuch_database_find_doc_ids (message->notmuch, "type", "mail", &mail_doc, &mail_doc_end);