]> git.notmuchmail.org Git - notmuch/commitdiff
lib: catch Xapian exceptions in n_m_count_files
authorDavid Bremner <david@tethera.net>
Sun, 5 Jul 2020 13:00:21 +0000 (10:00 -0300)
committerDavid Bremner <david@tethera.net>
Tue, 14 Jul 2020 10:31:37 +0000 (07:31 -0300)
This will require some care for the caller to check the sign, and not
just add error returns into a running total.

lib/message.cc
lib/notmuch.h
test/T560-lib-error.sh

index 364cdc9d4e86764ddd5502f5e0034c1424a555ac..7713050a78a9d97c3a8ac9043fe1e807ae9804af 100644 (file)
@@ -1156,7 +1156,12 @@ notmuch_message_get_filenames (notmuch_message_t *message)
 int
 notmuch_message_count_files (notmuch_message_t *message)
 {
-    _notmuch_message_ensure_filename_list (message);
+    try {
+       _notmuch_message_ensure_filename_list (message);
+    } catch (Xapian::Error &error) {
+       LOG_XAPIAN_EXCEPTION (message, error);
+       return -1;
+    }
 
     return _notmuch_string_list_length (message->filename_list);
 }
index 50d804fa99f935fcbf00d5454b3639675aa687ef..693e507602942ce88dde01b5ba598552e193ec24 100644 (file)
@@ -1412,7 +1412,8 @@ notmuch_message_get_replies (notmuch_message_t *message);
 
 /**
  * Get the total number of files associated with a message.
- * @returns Non-negative integer
+ * @returns Non-negative integer for file count.
+ * @returns Negative integer for error.
  * @since libnotmuch 5.0 (notmuch 0.25)
  */
 int
index e1843d910938ad0399d83ecb29703fdc71bee3ca..1635d0e705330db53683615cd8358fc7b11ea3f9 100755 (executable)
@@ -487,7 +487,6 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Handle counting files from closed database"
-test_subtest_known_broken
 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
     {
         int result;