return value;
}
-/*
- * For special applications where we only want the thread id, reading
- * in all metadata is a heavy I/O penalty.
- */
-const char *
-_notmuch_message_get_thread_id_only (notmuch_message_t *message)
-{
-
- Xapian::TermIterator i = message->doc.termlist_begin ();
- Xapian::TermIterator end = message->doc.termlist_end ();
-
- message->thread_id = _notmuch_message_get_term (message, i, end,
- _find_prefix ("thread"));
- return message->thread_id;
-}
-
-
static void
_notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
{
}
/* Add "folder:" term for directory. */
-static notmuch_status_t
+NODISCARD static notmuch_status_t
_notmuch_message_add_folder_terms (notmuch_message_t *message,
const char *directory)
{
*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);
#define RECURSIVE_SUFFIX "/**"
/* Add "path:" terms for directory. */
-static notmuch_status_t
+NODISCARD 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;
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;
}
}
}
/* 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;
}
const char *direntry, *directory;
char *colon;
const std::string &term = *i;
+ notmuch_status_t term_status;
/* Terminate loop at first term without desired prefix. */
if (strncmp (term.c_str (), direntry_prefix, direntry_prefix_len))
message->notmuch,
directory_id);
- _notmuch_message_add_folder_terms (message, directory);
- _notmuch_message_add_path_terms (message, directory);
+ term_status = _notmuch_message_add_folder_terms (message, directory);
+ if (term_status)
+ return term_status;
+
+ term_status = _notmuch_message_add_path_terms (message, directory);
+ if (term_status)
+ return term_status;
}
return status;
/* 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;
+
+ status = _notmuch_message_add_folder_terms (message, directory);
+ if (status)
+ return status;
- _notmuch_message_add_folder_terms (message, directory);
- _notmuch_message_add_path_terms (message, directory);
+ status = _notmuch_message_add_path_terms (message, directory);
+ if (status)
+ return status;
talloc_free (local);
*
* 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)
*
* 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)
char *to_set, *to_clear;
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+ status = _notmuch_database_ensure_writable (message->notmuch);
+ if (status)
+ return status;
+
_get_maildir_flag_actions (message, &to_set, &to_clear);
for (filenames = notmuch_message_get_filenames (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);
}
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);