/* Add a message to this thread which is known to match the original
* search specification. The 'sort' parameter controls whether the
* oldest or newest matching subject is applied to the thread as a
- * whole. */
-static void
+ * whole. Returns 0 on success.
+ */
+static int
_thread_add_matched_message (notmuch_thread_t *thread,
notmuch_message_t *message,
notmuch_sort_t sort)
{
time_t date;
notmuch_message_t *hashed_message;
+ notmuch_bool_t is_set;
date = notmuch_message_get_date (message);
_thread_set_subject_from_message (thread, message);
}
- if (! notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
+ if (notmuch_message_get_flag_st (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, &is_set))
+ return -1;
+ if (! is_set)
thread->matched_messages++;
if (g_hash_table_lookup_extended (thread->message_hash,
}
_thread_add_matched_author (thread, _notmuch_message_get_author (hashed_message));
+ return 0;
}
static bool
notmuch_messages_valid (roots);
notmuch_messages_move_to_next (roots)) {
notmuch_message_t *message = notmuch_messages_get (roots);
- if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (thread->toplevel_list))
+ if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (
+ thread->toplevel_list))
_parent_or_toplevel (thread, message);
else
_notmuch_message_list_add_message (thread->toplevel_list, message);
if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
_notmuch_doc_id_set_remove (match_set, doc_id);
- _thread_add_matched_message (thread, message, sort);
+ if (_thread_add_matched_message (thread, message, sort)) {
+ thread = NULL;
+ goto DONE;
+ }
}
_notmuch_message_close (message);