]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message.cc
lib: define specialized get_thread_id for use in thread subquery
[notmuch] / lib / message.cc
index e819f27a40da831a0371b03fc8f56b938dabb8e2..b2067076effb9981c56a16ffdbd2ca4fdbe1c849 100644 (file)
@@ -318,6 +318,23 @@ _notmuch_message_get_term (notmuch_message_t *message,
     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)
 {
@@ -1961,7 +1978,7 @@ _notmuch_message_frozen (notmuch_message_t *message)
 
 notmuch_status_t
 notmuch_message_reindex (notmuch_message_t *message,
-                        notmuch_indexopts_t unused (*indexopts))
+                        notmuch_indexopts_t *indexopts)
 {
     notmuch_database_t *notmuch = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
@@ -2002,6 +2019,11 @@ notmuch_message_reindex (notmuch_message_t *message,
     ret = notmuch_message_remove_all_properties_with_prefix (message, "index.");
     if (ret)
        goto DONE; /* XXX TODO: distinguish from other error returns above? */
+    if (indexopts && notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE) {
+       ret = notmuch_message_remove_all_properties (message, "session-key");
+       if (ret)
+           goto DONE;
+    }
 
     /* re-add the filenames with the associated indexopts */
     for (; notmuch_filenames_valid (orig_filenames);
@@ -2042,7 +2064,7 @@ notmuch_message_reindex (notmuch_message_t *message,
        if (found == 0)
            _notmuch_message_set_header_values (message, date, from, subject);
 
-       ret = _notmuch_message_index_file (message, message_file);
+       ret = _notmuch_message_index_file (message, indexopts, message_file);
 
        if (ret == NOTMUCH_STATUS_FILE_ERROR)
            continue;