summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
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.
2021-03-20lib/open: use _finish_open in n_d_create_with_configDavid Bremner
This avoids reading the configuration file twice.
2021-03-20lib/open: factor out the second half of n_d_open_with_configDavid Bremner
The idea is to allow reuse in n_d_create_with_config. This is primarily code movement, with some changes in error messages to reduce the number of input parameters.
2021-03-20lib/open: reuse directory checks from n_d_c_with_configDavid Bremner
Make checks more uniform between creating new databases and opening existing ones.
2021-03-20lib/open: factor out library initializationDavid Bremner
This is slightly more tidy, but more importantly it allows for re-use of this code in n_d_create_with_config. That re-use will be crucial when we no longer call n_d_open_with_config from n_d_create_with_config.
2021-03-20lib: remove "path" from notmuch structDavid Bremner
This removes duplication between the struct element and the configuration string_map entry. Create a simple wrapper for setting the database path that makes sure the trailing / is stripped.
2021-03-20lib/open: allocate notmuch_t struct earlyDavid Bremner
This gives more flexibility in restructuring the database opening code.
2021-03-19lib/open: support NOTMUCH_DATABASE environment variableDavid Bremner
The additional code is trivial, but making sure we get the priority of various options correct takes a few tests.
2021-03-18lib: support reopening databases for write access.David Bremner
In the future Xapian will apparently support this more conveniently for the cases other than READ_ONLY => READ_ONLY Conceptually this function seems to fit better in lib/open.cc; database.cc is still large enough that moving the function makes sense.
2021-03-18lib: save path of xapian database in notmuch struct.David Bremner
This will allow re-opening in a different mode (read/write vs. read-only) with current Xapian API. It will also prove useful when updating the compact functions to support more flexible database location.
2021-03-18lib: publish API for notmuch_database_reopenDavid Bremner
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.
2021-03-13lib/open: free GKeyFileDavid Bremner
This fixes a small-to-medium (depending on size of config file) memory leak.
2021-03-13lib/config: free memory from traversing GKeyFileDavid Bremner
This fixes a few small memory leaks.
2021-03-13lib/open: free value from g_key_file_get_valueDavid Bremner
This fixes a small memory leak.
2021-03-13lib/open: use local talloc context in n_d_create_with_configDavid Bremner
This better matches the memory allocation semantics in notmuch_database_open_with_config.
2021-03-13lib: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc in the lib directory
2021-02-18Merge tag '0.31.4'David Bremner
notmuch 0.31.4 release
2021-02-15fix build failure with glib 2.67David Bremner
Based on a patch from Michael J Gruber [1]. As of glib 2.67 (more specifically [2]), including "gmime-extra.h" inside an extern "C" block causes build failures, because glib is using C++ features. Observing that "gmime-extra.h" is no longer needed in notmuch-private.h, which can simply delete that include, but we have to correspondingly move the includes which might include it (in particular crypto.h) out of the extern "C" block also. This seems less fragile than only moving gmime-extra, and relying on preprocessor sentinels to keep the deeper includes from happening. Move to the include to the outside of the extern block. [1]: id:aee618a3d41f7889a7449aa16893e992325a909a.1613055071.git.git@grubix.eu [2]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715
2021-02-14lib: use a stricter unused macroDavid Bremner
This would have caught bugs like the one corrected in the previous commit.
2021-02-14lib/open: remove incorrect unused attributeDavid Bremner
With the current unused macro in lib/notmuch-private.h this seems harmless, but is misleading, since the parameter is in fact used.
2021-02-06lib: add missing private status values.David Bremner
Many public status values have been added without being copied to the list of private status values.
2021-02-06lib/open: set HOOK_DIR on openDavid Bremner
This is a simple two step path search. Most error checking is deferred until running the hooks.
2021-02-06lib/config: add HOOK_DIRDavid Bremner
The hook directory configuration needs to be kept in synch with the other configuration information, so add scaffolding to support this at database opening time.
2021-02-06lib: introduce notmuch_database_create_with_configDavid Bremner
This takes a config path parameter, and can use that to decide the new database location.
2021-02-06lib: add NOTMUCH_STATUS_DATABASE_EXISTSDavid Bremner
It is desirable to distinguish between attempting to create a database that already exists, and more fatal errors like permission problems.
2021-02-06lib/database: move n_d_create* to open.ccDavid Bremner
This will help share code with n_d_open_with_config.
2021-02-06lib: add NOTMUCH_STATUS_NO_CONFIGDavid Bremner
This will allow client code to provide more meaningful diagnostics. In particular it will enable "notmuch new" to continue suggsting the user run "notmuch setup" to create a config after "notmuch new" is transitioned to the new configuration framework.