aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
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.
2021-02-06lib/open: factor out choosing database pathDavid Bremner
The plan is to share code with a new database creation function that has a similar API to n_d_open_with_config.
2021-02-06lib/config: add NOTMUCH_CONFIG_NEW_IGNOREDavid Bremner
This will be needed by (at least) the conversion of notmuch-new.c to the new config framework
2021-02-06lib: split notmuch_database_compactDavid Bremner
The "back end" function takes an open notmuch database, which should know its own path (i.e. the path needs to be cached in the configuration data).
2021-02-06lib/config: add _notmuch_config_cacheDavid Bremner
This is a simple convenience routine to cache a configuration value without writing it to the database.
2021-02-06lib: add notmuch_config_get_boolDavid Bremner
Booleans have no out of band values, so return a status for errors.
2021-02-06lib/config: make values iterators restartableDavid Bremner
This is relatively cheap, and makes it easier to transform existing code which uses arrays of pointers to store configuration lists.
2021-02-06lib/config: add config values iteratorDavid Bremner
This is intended to avoid duplicating the string splitting and traversal code for all clients of the config API.
2021-02-06lib/open: load default values for known configuration keys.David Bremner
This emulates the behaviour of notmuch_config_open defined in the CLI, in that it fills in default values if they are not otherwise defined.