aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-02-06lib/config: add notmuch_config_key_{get,set}David Bremner
By using an enum we can have better error detection than copy pasting key strings around. The question of what layer this belongs in is a bit tricky. Historically most of the keys are defined by the CLI. On the other hand features like excludes are supported in the library/bindings, and it makes sense to configure them from the library as well. The somewhat long prefix for notmuch_config_t is to avoid collisions with the existing usage in notmuch-client.h.
2021-02-06lib/open: add support for config profiles and default locationsDavid Bremner
Fill in the remainder of the documented functionality for n_d_open_with_config with respect to config file location. Similar searching default locations of the database file still needs to be added.
2021-02-06lib: add stub for notmuch_database_open_with_configDavid Bremner
Initially document the intended API and copy the code from notmuch_database_open_verbose. Most of the documented functionality is not there yet.
2021-02-06lib: cache configuration information from databaseDavid Bremner
The main goal is to allow configuration information to be temporarily overridden by a separate config file. That will require further changes not in this commit. The performance impact is unclear, and will depend on the balance between number of queries and number of distinct metadata items read on the first call to n_d_get_config.
2021-02-06lib: add _notmuch_string_map_setDavid Bremner
This will be used (and tested) by the configuration caching code to be added in the next commit.
2020-12-23lib/config: delay setting talloc destructorDavid Bremner
If Xapian has thrown an exception, it is not safe to invoke the destructor when freeing the list struct. (cherry picked from commit 43ba5ed7eca6e9f6433b8c2c2a9d834d4101b92a)
2020-12-23lib: factor out notmuch_database_open* related code to own fileDavid Bremner
Reduce the size of database.cc, and prepare for extending the database opening API
2020-12-23lib/config: delay setting talloc destructorDavid Bremner
If Xapian has thrown an exception, it is not safe to invoke the destructor when freeing the list struct.
2020-12-23lib: factor out prefix related code to its own fileDavid Bremner
Reduce the size of database.cc, and limit the scope of prefix_table, make sure it's accessed via a well-defined internal API.
2020-12-23lib: factor out feature name related code.David Bremner
database.cc is uncomfortably large, and some of the static data structures do not need to be shared as much as they are. This is a somewhat small piece to factor out, but it will turn out to be helpful to further refactoring.
2020-10-29lib/config: don't set destructor until iterator is initialized.David Bremner
As diagnosed by Olivier Taïbi in id:20201027100916.emry3k2wujod4xnl@galois.lan, if an exception is thrown while the initialization is happening (e.g. if the function is called on a closed database), then the destructor is (sometimes) invoked on an uninitialized Xapian object. Solve the problem by moving the setting of the destructor until after the placement new successfully completes. It is conceivable this might cause a memory leak, but that seems preferable to crashing, and in any case, there seems to be nothing better to be done if the initialization is failing things are in an undefined state by definition.
2020-08-09Fix typosJonas Bernoulli
2020-08-09emacs: Use makefile-gmake-mode in Makefile*sJonas Bernoulli
Use `makefile-gmake-mode' instead of `makefile-mode' because the former also highlights ifdef et al. while the latter does not. "./Makefile.global" and one "Makefile.local" failed to specify any major mode at all but doing so is necessary because Emacs does not automatically figure out that these are Makefiles (of any flavor).
2020-08-03test: regression test for traversing config list with closed dbDavid Bremner
Also mention error return in API docs
2020-08-03lib: fix return value for n_directory_deleteDavid Bremner
Falling out of the catch meant the error return was lost
2020-08-03lib: catch exceptions in n_directory_get_child_filesDavid Bremner
Also clarify API in error case.
2020-08-03lib: catch exceptions in n_directory_get_child_directoriesDavid Bremner
Also clarify API in error case.
2020-08-03lib: return NULL from n_d_get_default_indexopts on errorDavid Bremner
This is a rare and probably serious programming error, so better not to silently return a default value.
2020-07-28lib: replace use of static_cast for writable databasesDavid Bremner
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.
2020-07-28lib: encapsulate the use of notmuch_database_t field 'mode'David Bremner
The plan is to change the underlying representation.
2020-07-28lib: drop two gratuitous assignments to database modeDavid Bremner
I'm not sure what the point of modifying that right before destroying the object is. In a future commit I want to remove that element of the object, so simplify that task.
2020-07-22lib: fix error return bug with n_d_set_config.David Bremner
The catch block either needs to return, or the function needs to return "status". Choose the latter for consistency with n_d_get_config.
2020-07-22lib: rename _n_d_create to _n_d_find_or_createDavid Bremner
The error message and name were confusing when called in some "read only" context.
2020-07-22lib: convert relative filenames to absolute in n_d_index_fileDavid Bremner
The API docs promise to handle relative filenames, but the code did not do it. Also check for files outside the mail root, as implied by the API description. This fixes the bug reported at id:87sgdqo0rz.fsf@tethera.net
2020-07-22lib/n_d_needs_upgrade: handle error return from n_d_get_versionDavid Bremner
Also clarify documentation of error return from n_d_needs_upgrade.
2020-07-22lib/n_d_get_version: catch exceptions and clarify the APIDavid Bremner
notmuch_database_get_version previously returned 0 on some errors, but did not document this. Luckily 0 is not a valid database version.
2020-07-22lib: move deallocation of memory from n_d_close to n_d_destroyDavid Bremner
In order to mimic the "best effort" API of Xapian to provide information from a closed database when possible, do not destroy the Xapian database object too early. Because the pointer to a Xapian database is no longer nulled on close, introduce a flag to track whether the notmuch database is open or not.
2020-07-22lib: fix exception messages for n_m_message_*David Bremner
The original generic handler had an extra '%s' in the format string. Update tests that failed to catch this because the template to print status strings checked 'stat', which was not set.
2020-07-20lib: fix return value for n_m_reindexDavid Bremner
Also update the documentation for the behaviour of n_m_get_thread_id that this fix relies on.
2020-07-20lib: handle xapian exception in n_m_remove_all_tagsDavid Bremner
At least the exception we already catch should be reported properly.
2020-07-20lib: add notmuch_message_has_maildir_flag_stDavid Bremner
Initially the new function is mainly tested indirectly via the wrapper.
2020-07-20test: add regression test for notmuch_message_has_maildir_flagDavid Bremner
This passes the NULL return inside _ensure_maildir_flags does not break anything. Probably this should be handled more explicitely.
2020-07-18lib/thread: replace use of deprecated notmuch_message_get_flagDavid Bremner
This adds one more reason why _notmuch_thread_create might return NULL, but those were not previously enumerated, so no promises are broken.
2020-07-18lib/add-message: drop use of deprecated notmuch_message_get_flag.David Bremner
As a side effect, we revert the switch from notmuch_bool_t to bool here. This is because those two types are not actually compatible when passing by reference.
2020-07-18lib: catch exceptions in n_m_get_flag, provide n_m_get_flag_stDavid Bremner
It's not very nice to return FALSE for an error, so provide notmuch_message_get_flag_st as a migration path. Bump LIBNOTMUCH_MINOR_VERSION because the API is extended.
2020-07-14lib: use COERCE_STATUS in n_m_{add,remove}_tagDavid Bremner
Currently I don't know of a good way of testing this, but at least in principle a Xapian exception in _notmuch_message_{add,remove}_term would cause an abort in the library.
2020-07-14lib: catch Xapian exceptions in n_m_remove_tagDavid Bremner
The churn here is again mainly re-indentation.
2020-07-14lib: catch Xapian exceptions in n_m_add_tagDavid Bremner
This is mostly just (horizontal) code movement due to wrapping everything in a try / catch.
2020-07-14lib: catch Xapian exceptions in n_m_count_filesDavid Bremner
This will require some care for the caller to check the sign, and not just add error returns into a running total.
2020-07-14lib: catch Xapian exceptions in n_m_get_tagsDavid Bremner
This allows the function to return an error value rather than crashing.
2020-07-14lib: use LOG_XAPIAN_EXCEPTION in n_m_get_dateDavid Bremner
This should not change functionality, but does slightly reduce code duplication. Perhaps more importantly it allows consistent changes to all of the similar exception handling in message.cc.
2020-07-14lib: add regression test for n_m_get_date; clarify APIDavid Bremner
This function catches Xapian exceptions. The test is intended to make sure it stays that way.
2020-07-13lib: catch exceptions in n_m_get_filenamesDavid Bremner
This is essentially copied from the change to notmuch_message_get_filename
2020-07-13lib/n_m_g_filename: catch Xapian exceptions, document NULL returnDavid Bremner
This is the same machinery as applied for notmuch_message_get_{thread,message}_id
2020-07-13lib/n_m_get_replies: doc return, initial regression testDavid Bremner
We need to to set a query and retrieve the threads to meaningfully test this function.
2020-07-13lib/message: use LOG_XAPIAN_EXCEPTION in n_m_get_headerDavid Bremner
This is just for consistency, and a small reduction in the amount of boilerplate.
2020-07-11lib: migrate from Xapian ValueRangeProcessor to RangeProcessorDavid Bremner
This will be mandatory as of Xapian 1.5. The API is also more consistent with the FieldProcessor API, which helps code re-use a bit. Note that this switches to using the built-in Xapian support for prefixes on ranges (i.e. deleted code at beginning of ParseTimeRangeProcessor::operator(), added prefix to constructor). Another side effect of the migration is that we are generating smaller queries, using one OP_VALUE_RANGE instead of an AND of two OP_VALUE_* queries.
2020-07-11lib: migrate to post Xapian 1.3.4 compact supportDavid Bremner
The old API was deprecated in Xapian 1.3.4 and (will be) removed in 1.5.0
2020-07-03lib/message: catch exception in n_m_get_thread_idDavid Bremner
This allows us to return an error value from the library.
2020-07-03lib: catch error from closed db in n_m_get_message_idDavid Bremner
By catching it at the library top level, we can return an error value.