mu-find: insist on --linksdir for links

Fixes #2790.
This commit is contained in:
Dirk-Jan C. Binnema
2024-12-04 23:18:15 +02:00
parent ffb3563f11
commit 1b2d9d3847
2 changed files with 9 additions and 4 deletions

View File

@ -127,15 +127,16 @@ Output results in the specified format.
- The default is *plain*, i.e normal output with one line per message. - The default is *plain*, i.e normal output with one line per message.
- *links* outputs the results as a maildir with symbolic links to the found - *links* outputs the results as a maildir with symbolic links to the found
messages. This enables easy integration with mail-clients (see below for more messages. This enables easy integration with mail-clients (see below for more
information). information). This requires *--linksdir*.
- *xml* formats the search results as XML. - *xml* formats the search results as XML.
- *sexp* formats the search results as an s-expression as used in Lisp programming - *sexp* formats the search results as an s-expression as used in Lisp programming
environments. environments.
** --linksdir _dir_ and -c, --clearlinks ** --linksdir _dir_ and -c, --clearlinks
When using *--format=links*, output the results as a maildir with symbolic links to When using *--format=links*, output the results as a maildir with symbolic links
the found messages. This enables easy integration with mail-clients (see below to the found messages. This enables easy integration with mail-clients (see
for more information). *mu* will create the maildir if it does not exist yet. below for more information). *mu* will create the maildir if it does not exist
yet.
If you specify *--clearlinks*, existing symlinks will be cleared from the target If you specify *--clearlinks*, existing symlinks will be cleared from the target
directories; this allows for re-use of the same maildir. However, this option directories; this allows for re-use of the same maildir. However, this option

View File

@ -164,6 +164,10 @@ get_query(const Store& store, const Options& opts)
static Result<void> static Result<void>
prepare_links(const Options& opts) prepare_links(const Options& opts)
{ {
// XXX: can this be done as part of the option-parsing?
if (opts.find.linksdir.empty())
return Err(Error::Code::InvalidArgument, "--linksdir is required");
/* note, mu_maildir_mkdir simply ignores whatever part of the /* note, mu_maildir_mkdir simply ignores whatever part of the
* mail dir already exists */ * mail dir already exists */
if (auto&& res = maildir_mkdir(opts.find.linksdir, 0700, true); !res) if (auto&& res = maildir_mkdir(opts.find.linksdir, 0700, true); !res)