X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fmessage.cc;h=0c2eeab55b6e3eceb08bade87b08e6c9ac333daa;hb=a3444e873f27a379600428b1ccf9ef9889553709;hp=d23e64abaa06b4c1d3327f4bedd638e52dd5cf64;hpb=d7d4c729ab3b74eaaebe64cb8c7383b0ea06cec0;p=notmuch diff --git a/lib/message.cc b/lib/message.cc index d23e64ab..0c2eeab5 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -93,8 +93,10 @@ _notmuch_message_destructor (notmuch_message_t *message) #define LOG_XAPIAN_EXCEPTION(message, error) _log_xapian_exception (__location__, message, error) static void -_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) { +_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 at %s: %s\n", where, @@ -286,7 +288,8 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch, doc_id = _notmuch_database_generate_doc_id (notmuch); } catch (const Xapian::Error &error) { - _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n", + _notmuch_database_log (notmuch_message_get_database (message), + "A Xapian exception occurred creating message: %s\n", error.get_msg ().c_str ()); notmuch->exception_reported = true; *status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; @@ -318,6 +321,7 @@ _notmuch_message_get_term (notmuch_message_t *message, return NULL; const std::string &term = *i; + if (strncmp (term.c_str (), prefix, prefix_len)) return NULL; @@ -455,7 +459,8 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message, void *field) /* all the way without an exception */ break; } catch (const Xapian::DatabaseModifiedError &error) { - notmuch_status_t status = _notmuch_database_reopen (message->notmuch); + notmuch_status_t status = notmuch_database_reopen (message->notmuch, + NOTMUCH_DATABASE_MODE_READ_ONLY); if (status != NOTMUCH_STATUS_SUCCESS) INTERNAL_ERROR ("unhandled error from notmuch_database_reopen: %s\n", notmuch_status_to_string (status)); @@ -1097,7 +1102,7 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message) *colon = '\0'; - db_path = notmuch_database_get_path (message->notmuch); + db_path = notmuch_config_get (message->notmuch, NOTMUCH_CONFIG_MAIL_ROOT); directory = _notmuch_database_get_directory_path (local, message->notmuch, @@ -1322,8 +1327,6 @@ _notmuch_message_upgrade_last_mod (notmuch_message_t *message) void _notmuch_message_sync (notmuch_message_t *message) { - Xapian::WritableDatabase *db; - if (_notmuch_database_mode (message->notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY) return; @@ -1342,8 +1345,8 @@ _notmuch_message_sync (notmuch_message_t *message) _notmuch_database_new_revision ( message->notmuch))); - db = static_cast (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; } @@ -1353,7 +1356,6 @@ notmuch_status_t _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; @@ -1370,8 +1372,7 @@ _notmuch_message_delete (notmuch_message_t *message) if (status) return status; - db = static_cast (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); @@ -1769,6 +1770,7 @@ notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag) { notmuch_status_t status; notmuch_bool_t ret; + status = notmuch_message_has_maildir_flag_st (message, flag, &ret); if (status) return FALSE; @@ -1782,14 +1784,14 @@ notmuch_message_has_maildir_flag_st (notmuch_message_t *message, notmuch_bool_t *is_set) { notmuch_status_t status; - + if (! is_set) return NOTMUCH_STATUS_NULL_POINTER; status = _ensure_maildir_flags (message, false); if (status) return status; - + *is_set = message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL); return NOTMUCH_STATUS_SUCCESS; } @@ -2083,8 +2085,8 @@ notmuch_message_remove_all_tags (notmuch_message_t *message) private_status = _notmuch_message_remove_term (message, "tag", tag); if (private_status) { return COERCE_STATUS (private_status, - "_notmuch_message_remove_term return unexpected value: %d\n", - private_status); + "_notmuch_message_remove_term return unexpected value: %d\n", + private_status); } } @@ -2206,8 +2208,8 @@ notmuch_message_reindex (notmuch_message_t *message, orig_thread_id = notmuch_message_get_thread_id (message); if (! orig_thread_id) { /* the following is correct as long as there is only one reason - n_m_get_thread_id returns NULL - */ + * n_m_get_thread_id returns NULL + */ return NOTMUCH_STATUS_XAPIAN_EXCEPTION; }