[PATCH 10/10] lib: fix return value for n_m_reindex

Subject: [PATCH 10/10] lib: fix return value for n_m_reindex

Date: Wed, 8 Jul 2020 21:17:09 -0300

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


Also update the documentation for the behaviour of n_m_get_thread_id
that this fix relies on.
---
 lib/message.cc         | 6 ++++--
 lib/notmuch.h          | 4 ++--
 test/T560-lib-error.sh | 1 -
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 09708ed9..87448101 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -2205,8 +2205,10 @@ notmuch_message_reindex (notmuch_message_t *message,
     /* Save in case we need to delete message */
     orig_thread_id = notmuch_message_get_thread_id (message);
     if (! orig_thread_id) {
-	/* XXX TODO: make up new error return? */
-	INTERNAL_ERROR ("message without thread-id");
+	/* the following is correct as long as there is only one reason
+	   n_m_get_thread_id returns NULL
+	*/
+	return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
     }
 
     /* strdup it because the metadata may be invalidated */
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 9a19e2f7..97ebc17d 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1378,8 +1378,8 @@ notmuch_message_get_message_id (notmuch_message_t *message);
  * notmuch_message_destroy on 'message' or until a query from which it
  * derived is destroyed).
  *
- * This function will not return NULL since Notmuch ensures that every
- * message belongs to a single thread.
+ * This function will return NULL if triggers an unhandled Xapian
+ * exception.
  */
 const char *
 notmuch_message_get_thread_id (notmuch_message_t *message);
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index e303720c..536ff701 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -679,7 +679,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Handle reindexing message with closed db"
-test_subtest_known_broken
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
     {
         notmuch_status_t status;
-- 
2.27.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: