* This change will not be reflected in the database until the next
* call to _notmuch_message_sync.
*
+ * If this message still has other filenames, returns
+ * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID.
+ *
* Note: This function does not remove a document from the database,
* even if the specified filename is the only filename for this
* message. For that functionality, see
"file-direntry", direntry);
status = COERCE_STATUS (private_status,
"Unexpected error from _notmuch_message_remove_term");
+ if (status)
+ return status;
/* Re-synchronize "folder:" terms for this message. This requires:
* 1. removing all "folder:" terms
if (strncmp ((*i).c_str (), direntry_prefix, direntry_prefix_len))
break;
+ /* Indicate that there are filenames remaining. */
+ status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
+
direntry = (*i).c_str ();
direntry += direntry_prefix_len;
db->replace_document (message->doc_id, message->doc);
}
+/* Delete a message document from the database. */
+notmuch_status_t
+_notmuch_message_delete (notmuch_message_t *message)
+{
+ notmuch_status_t status;
+ Xapian::WritableDatabase *db;
+
+ status = _notmuch_database_ensure_writable (message->notmuch);
+ if (status)
+ return status;
+
+ db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
+ db->delete_document (message->doc_id);
+ return NOTMUCH_STATUS_SUCCESS;
+}
+
/* Ensure that 'message' is not holding any file object open. Future
* calls to various functions will still automatically open the
* message file as needed.
/* 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). */
+ * also non-prefixed). */
notmuch_private_status_t
_notmuch_message_gen_terms (notmuch_message_t *message,
const char *prefix_name,
new_status = _notmuch_message_remove_filename (message,
filename);
/* Hold on to only the first error. */
- if (! status && new_status) {
+ if (! status && new_status
+ && new_status != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
status = new_status;
continue;
}