From 02a0dc4333d70b8793d5ac2b7a7557c6f7251c4f Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 23 Aug 2025 09:16:02 +0300 Subject: [PATCH] mu-server: implement exposing the socket-path Add the scm-socket-path to the ping-properties we expose for mu4e. --- lib/mu-server.cc | 38 +++++++++++++++++++++++++------------- lib/mu-server.hh | 1 + 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 13fb63c9..20bdc972 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -132,7 +132,8 @@ struct Server::Private { {} ~Private() { - indexer().stop(); + if (have_indexer_) + indexer().stop(); if (!tmp_dir_.empty()) remove_directory(tmp_dir_); } @@ -145,7 +146,7 @@ struct Server::Private { // acccessors Store& store() { return store_; } const Store& store() const { return store_; } - Indexer& indexer() { return store().indexer(); } + Indexer& indexer() { have_indexer_ = true; return store().indexer(); } void do_index(const Indexer::Config& conf); //CommandMap& command_map() const { return command_map_; } @@ -212,6 +213,8 @@ private: const CommandHandler command_handler_; std::atomic keep_going_{}; std::string tmp_dir_; + + bool have_indexer_{}; }; static void @@ -1021,15 +1024,19 @@ Server::Private::ping_handler(const Command& cmd) for (auto&& addr : store().config().get()) addrs.add(addr); - output_sexp(Sexp() - .put_props(":pong", "mu") - .put_props(":props", - Sexp().put_props( - ":version", VERSION, - ":personal-addresses", std::move(addrs), - ":database-path", store().path(), - ":root-maildir", store().root_maildir(), - ":doccount", storecount))); + Sexp props = Sexp().put_props( + ":version", VERSION, + ":personal-addresses", std::move(addrs), + ":database-path", store().path(), + ":root-maildir", store().root_maildir(), + ":doccount", storecount); + + if (!options_.socket_path.empty()) + props.put_props( + ":scm-socket-path", options_.socket_path); + + output_sexp(Sexp().put_props(":pong", "mu") + .put_props(":props", std::move(props))); } void @@ -1107,7 +1114,9 @@ Server::Private::view_mark_as_read(Store::Id docid, Message&& msg, bool rename) if (rename) move_opts |= Store::MoveOptions::ChangeName; - const auto ids{Store::id_vec(unwrap(store().move_message(docid, {}, nflags, move_opts)))}; + const auto ids{Store::id_vec( + unwrap(store().move_message(docid, {}, + nflags, move_opts)))}; for (auto&& [id, moved_msg]: store().find_messages(ids)) output(mu_format("({} {})", id == docid ? ":view" : ":update", msg_sexp_str(moved_msg, id, {}))); @@ -1142,7 +1151,10 @@ Server::Private::view_handler(const Command& cmd) Server::Server(Store& store, const Server::Options& opts, Server::Output output) : priv_{std::make_unique(store, opts, output)} -{} +{ + mu_message("created server with store @ {}; maildir @ {}", + store.path(), store.root_maildir()); +} Server::~Server() = default; diff --git a/lib/mu-server.hh b/lib/mu-server.hh index 0ceaa68f..79f18d0b 100644 --- a/lib/mu-server.hh +++ b/lib/mu-server.hh @@ -51,6 +51,7 @@ public: struct Options { bool allow_temp_file; /**< temp file optimization allowed? */ + std::string socket_path; /**< Socket path or empty */ }; /**