_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) {
notmuch_database_t *notmuch = notmuch_message_get_database (message);
_notmuch_database_log (notmuch,
- "A Xapian exception occurred %s retrieving %s : %s\n",
+ "A Xapian exception occurred at %s: %s\n",
where,
error.get_msg ().c_str ());
notmuch->exception_reported = true;
return NULL;
}
- if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+ if (_notmuch_database_mode (notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY)
INTERNAL_ERROR ("Failure to ensure database is writable.");
try {
void
_notmuch_message_sync (notmuch_message_t *message)
{
- Xapian::WritableDatabase *db;
-
- if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
+ if (_notmuch_database_mode (message->notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY)
return;
if (! message->modified)
_notmuch_database_new_revision (
message->notmuch)));
- db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
- db->replace_document (message->doc_id, message->doc);
+ message->notmuch->writable_xapian_db->
+ replace_document (message->doc_id, message->doc);
message->modified = false;
}
_notmuch_message_delete (notmuch_message_t *message)
{
notmuch_status_t status;
- Xapian::WritableDatabase *db;
const char *mid, *tid, *query_string;
notmuch_message_t *ghost;
notmuch_private_status_t private_status;
if (status)
return status;
- db = static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db);
- db->delete_document (message->doc_id);
+ message->notmuch->writable_xapian_db->delete_document (message->doc_id);
/* if this was a ghost to begin with, we are done */
private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
/* Save in case we need to delete message */
orig_thread_id = notmuch_message_get_thread_id (message);
if (! orig_thread_id) {
- /* XXX TODO: make up new error return? */
- INTERNAL_ERROR ("message without thread-id");
+ /* the following is correct as long as there is only one reason
+ n_m_get_thread_id returns NULL
+ */
+ return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
}
/* strdup it because the metadata may be invalidated */