summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-09-10lib: use 'localhost' rather than fqdn for default mail address.David Bremner
As discussed in the thread starting at [1], the fully qualified domain name is a bit tricky to get reproducibly, might reveal information people prefer to keep private, and somewhat unlikely to provide reliable mail routing. The new approach of $current_username@localhost is better for the first two considerations, and probably at least as good as a test mail address. [1]: id:87sfyibqhj.fsf@tethera.net
2021-08-18Merge tag 'debian/0.32.3-1'David Bremner
notmuch release 0.32.3-1 for unstable (sid) [dgit] [dgit distro=debian no-split --quilt=linear]
2021-08-17lib/open: look in MAILDIR for database, as documented.David Bremner
This fixes the bug id:87bl9lx864.fsf@kisara.moe
2021-08-17lib: bump libnotmuch minor versionAustin Ray
Notmuch 0.32 corresponds to libnotmuch 5.4 as indicated by docstrings; however, the minor number wasn't bumped. Any libnotmuch downstream consumer using the LIBNOTMUCH_CHECK_VERSION macro to support multiple versions won't be able to access the new 5.4 functions. Signed-off-by: Austin Ray <austin@austinray.io>
2021-08-17lib: correct deprecated db open functions' docsAustin Ray
Both notmuch_database_open() and notmuch_database_open_verbose()'s documentation state they call notmuch_database_open_with_config() with config_path=NULL; however, their implementations pass an empty string. The empty string is the correct value to maintain their original behavior of not loading the user's configuration so their documentation is incorrect.
2021-06-27lib: update transaction documentationDavid Bremner
Partly this is to recognize the semantics we inherit from Xapian, partly to mention the new autocommit feature.
2021-06-27lib: autocommit after some number of completed transactionsDavid Bremner
This change addresses two known issues with large sets of changes to the database. The first is that as reported by Steven Allen [1], notmuch commits are not "flushed" when they complete, which means that if there is an open transaction when the database closes (or e.g. the program crashes) then all changes since the last commit will be discarded (nothing is irrecoverably lost for "notmuch new", as the indexing process just restarts next time it is run). This does not really "fix" the issue reported in [1]; that seems rather difficult given how transactions work in Xapian. On the other hand, with the default settings, this should mean one only loses less than a minutes worth of work. The second issue is the occasionally reported "storm" of disk writes when notmuch finishes. I don't yet have a test for this, but I think committing as we go should reduce the amount of work when finalizing the database. [1]: id:20151025210215.GA3754@stebalien.com
2021-06-27lib/config: add NOTMUCH_CONFIG_AUTOCOMMITDavid Bremner
This will be used to control how often atomic transactions are committed.
2021-06-27database/close: remove misleading code / commentDavid Bremner
Unfortunately, it doesn't make a difference if we call cancel_transaction or not, all uncommited changes are discarded if there is an open (unflushed) transaction.
2021-06-27lib/database: fix style mistake.David Bremner
The spacing of the declaration was wrong in ea30110.
2021-06-25Merge branch 'release'David Bremner
2021-06-25lib: write talloc report in notmuch_database_destroyDavid Bremner
Since most memory allocation is (ultimately) in the talloc context defined by a notmuch_database_t pointer, this gives a more complete view of memory still allocated at program shutdown. We also change the talloc report in notmuch.c to mode "a" to avoid clobbering the newly reported log.
2021-06-25lib/config: fix memory leakDavid Bremner
This commit fixes a small memory leak (per iterator restart) by actually using the talloc context intended to be blown away on restart.
2021-06-05lib/message: use passed database for error handlingDavid Bremner
'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.
2021-06-05lib/{open,message}: make some internal functions staticDavid Bremner
They are not used outside their file, so being extern seems like an oversight
2021-05-23lib/thread: add common prefix to debug messages, join linesDavid Bremner
This will simplify filtering these message, e.g. in the test suite.
2021-05-22Merge branch 'release'David Bremner
2021-05-22lib/n_d_index_file: re-use thread-id of existing messageDavid Bremner
This prevents the message document getting multiple thread-id terms when there are multiple files with the same message-id. This change shifts some thread ids, requiring adjustments to other tests.
2021-05-15Merge branch 'release'David Bremner
2021-05-15lib/open: restore default database path of $HOME/mailDavid Bremner
Although this default worked for "notmuch config get", it didn't work most other places. Restore the previous functionality, with the wrinkle that XDG locations will shadow $HOME/mail if they exist. This fixes a bug reported by Jack Kamm in id:87eeefdc8b.fsf@gmail.com
2021-05-14lib/message: mark flag2tag as constDavid Bremner
This table is intended to be immutable
2021-05-14lib/generate_thread_id: move static buffer to notmuch_database_tDavid Bremner
Work towards the goal of concurrent access to different Xapian databases from the same process.
2021-05-13lib: make glib initialization thread-safeDavid Bremner
In principle this could be done without depending on C++11 features, but these features should be available since gcc 4.8.1, and this localized usage is easy to replace if it turns out to be problematic for portability.
2021-05-12lib/notmuch_database_reopen: reload some database metadataDavid Bremner
In some uses of reopen, new documents and threads maybe have been added, and e.g. compaction may have changed the uuid.
2021-05-10lib/config: expand relative paths when reading from databaseDavid Bremner
This makes the treatment of relative paths consistent between the database and config files.
2021-05-10lib/config: canonicalize paths relative to $HOME.David Bremner
Prior to 0.32, notmuch had the (undocumented) behaviour that it expanded a relative value of database.path with respect to $HOME. In 0.32 this was special cased for database.path but broken for database.mail_root, which causes problems for at least notmuch-new when database.path is set to a relative path. The change in T030-config.sh reflects a user visible, but hopefully harmless behaviour change; the expanded form of the paths will now be printed by notmuch config.
2021-04-24lib/config: remove early free in _get_email_from_passwd_fileDavid Bremner
This (obvious) bug was caused by cut&pasting the code from notmuch-config.c into the library and adding on a return at the end.
2021-04-24compat: rename {,notmuch_}canonicalize_file_nameĐoàn Trần Công Danh
When compat canonicalize_file_name was introduced, it was limited to C code only because it was used by C code only during that time. >From 5ec6fd4d, (lib/open: check for split configuration when creating database., 2021-02-16), lib/open.cc, which is C++, relies on the existent of canonicalize_file_name. However, we can't blindly enable canonicalize_file_name for C++ code, because different implementation has different additional signature for C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to {C,CXX}FLAGS. Let's move our implementation into a util library. Helped-by: Tomi Ollila <tomi.ollila@iki.fi> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2021-04-18lib/n_d_index_file: check return value from _n_m_add_filenameDavid Bremner
Ignoring this return value seems like a bad idea in general, and in particular it has been hiding one or more bugs related to handling long directory names.
2021-04-18lib: directly traverse postlists in _n_message_deleteDavid Bremner
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.
2021-03-27lib: provide notmuch_config_pathDavid Bremner
Since the library searches in several locations for a config file, the caller does not know which of these is chosen in the usual case of passing NULL as a config file. This changes provides an API for the caller to retrieve the name of the config file chosen. It will be tested in a following commit.
2021-03-27CLI+lib: detect missing database in split configurations.David Bremner
Eventually we want to do all opening of databases in the top level (main function). This means that detection of missing databases needs to move out of subcommands. It also requires updating the library to use the new NO_DATABASE status code.
2021-03-27lib: add NOTMUCH_STATUS_NO_DATABASEDavid Bremner
This will allow more precise return values from various open related functions.
2021-03-27CLI/config: migrate notmuch_config_open to new configDavid Bremner
notmuch_config_open will be preserved in the medium term for use by the commands that are manipulating the config file directly (config and setup)
2021-03-27lib/open: canonicalize relative path read from config fileDavid Bremner
This matches functionality in the the CLI function notmuch_config_get_database_path, which was previously used in the CLI code for all calls to open a database.
2021-03-27lib/config: set default for primary user emailDavid Bremner
This is mainly copying code from the CLI into the lib. The CLI copy will be deleted in a later commit.
2021-03-27lib/config: set defaults for user full nameDavid Bremner
This just copies code from from the CLI into the library. New test infrastructure is needed because apparently we have never tested this code path.
2021-03-27lib/config: add config_pairs iteratorsDavid Bremner
The layer of shims here seems a bit wasteful compared to just calling the corresponding string map functions directly, but it allows control over the API (calling with notmuch_database_t *) and flexibility for future changes.
2021-03-27lib/config: add notmuch_config_get_values_stringDavid Bremner
This is to support the less common (at least in the notmuch codebase) case of accessing a ;-delimited list config value with an arbitrary string key.
2021-03-27lib: provide notmuch_database_load_configDavid Bremner
This is mainly targetted at notmuch-config.c, or similar applications that don't necessarily need both a configuration file and a database to exist.
2021-03-27lib/open: pull _load_key_file out of _choose_database_pathDavid Bremner
Although this increases code duplication, it also increases flexibility in handling various combinations of missing config file and missing database.
2021-03-27lib: add missing status stringsDavid Bremner
2021-03-27lib/open: fix leaks calling _trial_openDavid Bremner
_trial_open can't know if the PATH_ERROR return value will cause the error message to be returned from the library, so it's up the caller to clean up if not.
2021-03-20lib/config: add configuration variable for backup directoryDavid Bremner
Like the hook directory, we primarily need a way to communicate this directory between various components, but we may as well let the user configure it. Most of the diff is generalizing choose_hook_dir to work for both backup and hook directories.
2021-03-20lib/open: fix hook directory calculation in split configurationDavid Bremner
Choose sibling directory of xapian database, as .notmuch may not exist. libgen.h is already used in debugger.c, so it is not a new dependency / potential portability problem.
2021-03-20lib/compact: enable split configDavid Bremner
This promotes _choose_xapian_path from static to extern linkage in order to share between open.cc and database.cc.
2021-03-20lib/open: support XDG_DATA_HOME as a fallback database location.David Bremner
This changes some error reporting, either intentionally by reporting the highest level missing directory, or by side effect from looking in XDG locations when given null database location.
2021-03-20lib/open: check for split configuration when creating database.David Bremner
The main functionality will be tested when notmuch-new is converted to support split configuration. Here only the somewhat odd case of split mail root which is actually symlinked to the database path is tested.
2021-03-20lib: support splitting mail from database location.David Bremner
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.
2021-03-20lib/open: Use check for existing database by trial openingDavid Bremner
This is a bit heavyweight for now, but it will make more sense when we check multiple locations for the Xapian database.