From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 6/8] lib/message: check return status of _n_m_{add,remove}_term
Date: Mon, 23 May 2022 20:38:59 -0300 [thread overview]
Message-ID: <20220523233901.3506880-7-david@tethera.net> (raw)
In-Reply-To: <20220523233901.3506880-1-david@tethera.net>
Xapian exceptions are not something that can be ignored, in general.
---
lib/message.cc | 43 ++++++++++++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 09e5660b..94be0f76 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -827,7 +827,10 @@ _notmuch_message_add_folder_terms (notmuch_message_t *message,
*folder = '\0';
}
- _notmuch_message_add_term (message, "folder", folder);
+ if (notmuch_status_t status = COERCE_STATUS (_notmuch_message_add_term (message, "folder",
+ folder),
+ "adding folder term"))
+ return status;
talloc_free (folder);
@@ -842,8 +845,13 @@ static notmuch_status_t
_notmuch_message_add_path_terms (notmuch_message_t *message,
const char *directory)
{
+ notmuch_status_t status;
+
/* Add exact "path:" term. */
- _notmuch_message_add_term (message, "path", directory);
+ status = COERCE_STATUS (_notmuch_message_add_term (message, "path", directory),
+ "adding path term");
+ if (status)
+ return status;
if (strlen (directory)) {
char *path, *p;
@@ -856,7 +864,10 @@ _notmuch_message_add_path_terms (notmuch_message_t *message,
for (p = path + strlen (path) - 1; p > path; p--) {
if (*p == '/') {
strcpy (p, RECURSIVE_SUFFIX);
- _notmuch_message_add_term (message, "path", path);
+ status = COERCE_STATUS (_notmuch_message_add_term (message, "path", path),
+ "adding path term");
+ if (status)
+ return status;
}
}
@@ -864,7 +875,10 @@ _notmuch_message_add_path_terms (notmuch_message_t *message,
}
/* Recursive all-matching path:** for consistency. */
- _notmuch_message_add_term (message, "path", "**");
+ status = COERCE_STATUS (_notmuch_message_add_term (message, "path", "**"),
+ "adding path term");
+ if (status)
+ return status;
return NOTMUCH_STATUS_SUCCESS;
}
@@ -943,7 +957,10 @@ _notmuch_message_add_filename (notmuch_message_t *message,
/* New file-direntry allows navigating to this message with
* notmuch_directory_get_child_files() . */
- _notmuch_message_add_term (message, "file-direntry", direntry);
+ status = COERCE_STATUS (_notmuch_message_add_term (message, "file-direntry", direntry),
+ "adding file-direntry term");
+ if (status)
+ return status;
_notmuch_message_add_folder_terms (message, directory);
_notmuch_message_add_path_terms (message, directory);
@@ -1465,7 +1482,7 @@ _notmuch_message_close (notmuch_message_t *message)
*
* This change will not be reflected in the database until the next
* call to _notmuch_message_sync. */
-notmuch_private_status_t
+NODISCARD notmuch_private_status_t
_notmuch_message_add_term (notmuch_message_t *message,
const char *prefix_name,
const char *value)
@@ -1540,7 +1557,7 @@ _notmuch_message_gen_terms (notmuch_message_t *message,
*
* This change will not be reflected in the database until the next
* call to _notmuch_message_sync. */
-notmuch_private_status_t
+NODISCARD notmuch_private_status_t
_notmuch_message_remove_term (notmuch_message_t *message,
const char *prefix_name,
const char *value)
@@ -2273,7 +2290,11 @@ notmuch_message_reindex (notmuch_message_t *message,
if (thread_id == NULL)
thread_id = orig_thread_id;
- _notmuch_message_add_term (message, "thread", thread_id);
+ ret = COERCE_STATUS (_notmuch_message_add_term (message, "thread", thread_id),
+ "adding thread term");
+ if (ret)
+ goto DONE;
+
/* Take header values only from first filename */
if (found == 0)
_notmuch_message_set_header_values (message, date, from, subject);
@@ -2291,7 +2312,11 @@ notmuch_message_reindex (notmuch_message_t *message,
}
if (found == 0) {
/* put back thread id to help cleanup */
- _notmuch_message_add_term (message, "thread", orig_thread_id);
+ ret = COERCE_STATUS (_notmuch_message_add_term (message, "thread", orig_thread_id),
+ "adding thread term");
+ if (ret)
+ goto DONE;
+
ret = _notmuch_message_delete (message);
} else {
_notmuch_message_sync (message);
--
2.35.2
next prev parent reply other threads:[~2022-05-23 23:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 23:38 incrementally improve error handling in notmuch_message* David Bremner
2022-05-23 23:38 ` [PATCH 1/8] test: define test_private_C David Bremner
2022-05-23 23:38 ` [PATCH 2/8] lib/message: catch exceptions in _n_m_add_term David Bremner
2022-05-23 23:38 ` [PATCH 3/8] test: _notmuch_message_remove_term catches exceptions David Bremner
2022-05-23 23:38 ` [PATCH 4/8] lib/message: drop _notmuch_message_get_thread_id_only David Bremner
2022-05-23 23:38 ` [PATCH 5/8] lib: define macro NODISCARD David Bremner
2022-05-23 23:38 ` David Bremner [this message]
2022-05-23 23:39 ` [PATCH 7/8] lib/message: check return status from _n_m_add_{path,folder}_terms David Bremner
2022-05-23 23:39 ` [PATCH 8/8] test: error handling in _n_message_{add,remove}_filename David Bremner
2022-06-25 19:00 ` incrementally improve error handling in notmuch_message* David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220523233901.3506880-7-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).