lib/message: check message type before deleting document It isn't really clear how this worked before. Traversing the terms of a document after deleting it from the database seems likely to be undefined behaviour at best
lib/message-property: sync removed properties to the database _notmuch_message_remove_all_properties wasn't syncing the message back to the database but was still invalidating the metadata, giving the impression the properties had actually been removed. Also move the metadata invalidation to _notmuch_message_remove_terms to be closer to what's done in _notmuch_message_modify_property and _notmuch_message_remove_term.
lib: add better diagnostics for over long filenames. Previously we just crashed with an internal error. With this change, the caller can handle it better. Update notmuch-new so that it doesn't crash with "unknown error code" because of this change.
lib/message: move xapian call inside try/catch block in _n_m_delete The call to delete_document can throw exceptions (and can happen in practice [1]), so catch the exception and extract the error message. As a side effect, also move the call to _n_m_has_term inside the try/catch. This should not change anything as that function already traps any Xapian exceptions. [1]: id:wwuk039sk2p.fsf@chaotikum.eu
lib: check for writable db in n_m_tags_maildir_flags The database needs to be writable because the list of stored file names will change in general.
lib/message: check return status from _n_m_add_{path,folder}_terms Mainly to propagate information about Xapian exceptions.
lib/message: check return status of _n_m_{add,remove}_term Xapian exceptions are not something that can be ignored, in general.
lib/message: drop _notmuch_message_get_thread_id_only This function has been unused since commit 4083fd8.
lib/message: catch exceptions in _n_m_add_term Some code movement is needed to make sure the cache is only invalidated when the Xapian operation succeeds.
lib/message: use false from stdbool.h As far as I know, this is just a style / consistency thing, unless notmuch code starts defining FALSE inconsistently with false.
lib: fix uninitialized field in message objects. Initially reported by Eliza Vasquez [1] (via valgrind). [1]: id:87o7zxj086.fsf@eliza.
lib/message: use passed database for error handling 'message' should always be initialized if we reach here, but in case it is not, we still want to be able to log an error message.
lib/{open,message}: make some internal functions static They are not used outside their file, so being extern seems like an oversight
lib/message: mark flag2tag as const This table is intended to be immutable
lib: directly traverse postlists in _n_message_delete This is intended to fix the slow behaviour of "notmuch new" (and possibly "notmuch reindex") when large numbers of files are deleted. The underlying issue [1] seems to be the Xapian glass backend spending a large amount of time in db.has_positions when running queries with large-ish amounts of unflushed changes. This commit removes two uses of Xapian queries [2], and replaces them with an approximation of what Xapian would do after optimizing the queries. This avoids the calls to has_positions (which are in any case un-needed because we are only using boolean terms here). [1] Thanks to "andres" on IRC for narrowing down the performance bottleneck. [2] Thanks to Olly Betts of Xapian fame for talking me a through a fix that does not require people to update Xapian.
lib: support splitting mail from database location. Introduce a new configuration value for the mail root, and use it to locate mail messages in preference to the database.path (which previously implied the mail messages were also in this location. Initially only a subset of the CLI is tested in a split configuration. Further changes will be needed for the remainder of the CLI to work in split configurations.
lib: publish API for notmuch_database_reopen Include the (currently unused) mode argument which will specify which mode to re-open the database in. Functionality and docs to be finalized in a followup commit.
lib: run uncrustify This is the result of running $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc in the lib directory
lib: replace use of static_cast for writable databases static_cast is a bit tricky to understand and error prone, so add a second pointer to (potentially the same) Xapian database object that we know has the right subclass.
lib: encapsulate the use of notmuch_database_t field 'mode' The plan is to change the underlying representation.