mu-init: insist that --maildir is absolute

This commit is contained in:
Dirk-Jan C. Binnema 2024-02-26 01:04:47 +02:00
parent 915335fd76
commit dcbcd697f4
4 changed files with 12 additions and 4 deletions

View File

@ -89,8 +89,12 @@ struct Store::Private {
Config make_config(XapianDb& xapian_db, const std::string& root_maildir,
Option<const Config&> conf) {
Config config{xapian_db};
if (!g_path_is_absolute(root_maildir.c_str()))
throw Error{Error::Code::File,
"root maildir path is not absolute ({})",
root_maildir};
Config config{xapian_db};
if (conf)
config.import_configurable(*conf);

View File

@ -77,8 +77,8 @@ public:
* Construct a store for a not-yet-existing document database
*
* @param path path to the database
* @param root_maildir maildir to use for this store
* @param config a configuration object
* @param root_maildir absolute path to maildir to use for this store
* @param conf a configuration object
*
* @return a store or an error
*/

View File

@ -22,7 +22,8 @@ use =<maildir>= as the root-maildir.
By default, *mu* uses the *MAILDIR* environment; if it is not set, it uses =~/Maildir=
if it is an existing directory. If neither of those can be used, the ~--maildir~
option is required.
option is required; it must be an absolute path (but ~~/~ expansion is
performed).
** --my-address=<email-address-or-regex>

View File

@ -45,6 +45,9 @@ Mu::mu_cmd_init(const Options& opts)
return Err(Error::Code::InvalidArgument,
"missing --maildir parameter and could "
"not determine default");
else if (!g_path_is_absolute(opts.init.maildir.c_str()))
return Err(Error{Error::Code::File,
"--maildir is not absolute"});
MemDb mdb;
Config conf{mdb};