]> git.notmuchmail.org Git - notmuch/blobdiff - message.cc
notmuch setup/new: Print progress once per second instead of after 1000 files.
[notmuch] / message.cc
index 6e15b51118be82b960fb13aae667241fdbf36048..75e752c800221f4c99837bf2dcd1a3faec8611ba 100644 (file)
@@ -276,8 +276,10 @@ notmuch_message_get_thread_id (notmuch_message_t *message)
        strncmp ((*i).c_str (), _find_prefix ("thread"),
                 strlen (_find_prefix ("thread"))) == 0)
     {
-       INTERNAL_ERROR ("Message with document ID of %d has duplicate thread IDs.\n",
-                       message->doc_id);
+       INTERNAL_ERROR ("Message %s has duplicate thread IDs: %s and %s\n",
+                       notmuch_message_get_message_id (message),
+                       message->thread_id,
+                       (*i).c_str () + 1);
     }
 #endif
 
@@ -442,6 +444,32 @@ _notmuch_message_add_term (notmuch_message_t *message,
     return NOTMUCH_PRIVATE_STATUS_SUCCESS;
 }
 
+/* Parse 'text' and add a term to 'message' for each parsed word. Each
+ * term will be added both prefixed (if prefix_name is not NULL) and
+ * also unprefixed). */
+notmuch_private_status_t
+_notmuch_message_gen_terms (notmuch_message_t *message,
+                           const char *prefix_name,
+                           const char *text)
+{
+    Xapian::TermGenerator *term_gen = message->notmuch->term_gen;
+
+    if (text == NULL)
+       return NOTMUCH_PRIVATE_STATUS_NULL_POINTER;
+
+    term_gen->set_document (message->doc);
+
+    if (prefix_name) {
+       const char *prefix = _find_prefix (prefix_name);
+
+       term_gen->index_text (text, 1, prefix);
+    }
+
+    term_gen->index_text (text);
+
+    return NOTMUCH_PRIVATE_STATUS_SUCCESS;
+}
+
 /* Remove a name:value term from 'message', (the actual term will be
  * encoded by prefixing the value with a short prefix). See
  * NORMAL_PREFIX and BOOLEAN_PREFIX arrays for the mapping of term
@@ -465,7 +493,14 @@ _notmuch_message_remove_term (notmuch_message_t *message,
     if (strlen (term) > NOTMUCH_TERM_MAX)
        return NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG;
 
-    message->doc.remove_term (term);
+    try {
+       message->doc.remove_term (term);
+    } catch (const Xapian::InvalidArgumentError) {
+       /* We'll let the philosopher's try to wrestle with the
+        * question of whether failing to remove that which was not
+        * there in the first place is failure. For us, we'll silently
+        * consider it all good. */
+    }
 
     talloc_free (term);