mu/mu4e: pass muhome to server (and provide some better error info)

This commit is contained in:
Dirk-Jan C. Binnema 2020-02-10 18:07:54 +02:00
parent f50360f94e
commit d90d2ce8ef
2 changed files with 13 additions and 5 deletions

View File

@ -213,6 +213,10 @@ struct Context {
GError *gerr{};
store = mu_store_new_writable (dbpath, NULL);
if (!store) {
const auto mu_init = format("mu init %s%s",
opts->muhome ? "--muhome=" : "",
opts->muhome ? opts->muhome : "");
if (gerr) {
if ((MuError)gerr->code == MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK)
print_error(MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK,
@ -221,14 +225,17 @@ struct Context {
else
print_error((MuError)gerr->code,
"cannot open database @ %s:%s; "
"please try 'mu init", dbpath,
gerr->message ? gerr->message : "something went wrong");
"please try '%s", dbpath,
gerr->message ? gerr->message : "something went wrong",
mu_init.c_str());
} else
print_error(MU_ERROR,
"cannot open database @ %s; pleasy try 'mu init'", dbpath);
"cannot open database @ %s; please try '%s'",
dbpath, mu_init.c_str());
throw Mu::Error (Error::Code::Store, &gerr/*consumed*/,
"failed to open database @ %s; please try 'mu init'", dbpath);
"failed to open database @ %s; please try '%s'",
dbpath, mu_init.c_str());
}
query = mu_query_new (store, &gerr);

View File

@ -252,7 +252,8 @@ Start the process if needed."
(unless (file-executable-p mu4e-mu-binary)
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
(let* ((process-connection-type nil) ;; use a pipe
(args '("server")))
(args (when mu4e-mu-home `(,(format"--muhome=%s" mu4e-mu-home))))
(args (cons "server" args)))
(setq mu4e~proc-buf "")
(setq mu4e~proc-process (apply 'start-process
mu4e~proc-name mu4e~proc-name