store: use Result<Store> builder, add auto upgrade

Make it a Result type, and add auto-upgrade (not enabled yet)
Update dependents.
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-09 20:58:35 +03:00
parent 7470a5f8ea
commit 80d84bf635
8 changed files with 201 additions and 85 deletions

View File

@ -116,16 +116,17 @@ report_error(const Mu::Error& err) noexcept
MuError
Mu::mu_cmd_server(const MuConfig* opts, GError** err)
try {
Store store{mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), false /*writable*/};
Server server{store, output_sexp_stdout};
auto store = Store::make(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), Store::Options::Writable);
if (!store)
throw store.error();
Server server{*store, output_sexp_stdout};
g_message("created server with store @ %s; maildir @ %s; debug-mode %s",
store.properties().database_path.c_str(),
store.properties().root_maildir.c_str(),
store->properties().database_path.c_str(),
store->properties().root_maildir.c_str(),
opts->debug ? "yes" : "no");
tty = ::isatty(::fileno(stdout));
const auto eval = std::string{opts->commands ? "(help :full t)"
: opts->eval ? opts->eval
: ""};