From 9987ceb7a76ec976cb6ddf2f090aec9ed46a5f4c Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 29 Jun 2022 07:48:01 +0300 Subject: [PATCH] cmd-find: fix link generation And some minor cleanups. --- mu/mu-cmd-find.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mu/mu-cmd-find.cc b/mu/mu-cmd-find.cc index cd7517fa..0d652716 100644 --- a/mu/mu-cmd-find.cc +++ b/mu/mu-cmd-find.cc @@ -173,42 +173,41 @@ get_query(const MuConfig* opts) return Ok(to_string_gchar(std::move(query))); } -static gboolean +static bool prepare_links(const MuConfig* opts, GError** err) { /* note, mu_maildir_mkdir simply ignores whatever part of the * mail dir already exists */ if (auto&& res = maildir_mkdir(opts->linksdir, 0700, true); !res) { res.error().fill_g_error(err); - return FALSE; + return false; } if (!opts->clearlinks) - return TRUE; + return false; if (auto&& res = maildir_clear_links(opts->linksdir); !res) { res.error().fill_g_error(err); - return FALSE; + return false; } - return TRUE; + return true; } static bool output_link(const Option& msg, const OutputInfo& info, const MuConfig* opts, GError** err) { - if (msg) - return true; - if (info.header) return prepare_links(opts, err); else if (info.footer) return true; + if (auto&& res = maildir_link(msg->path(), opts->linksdir); !res) { res.error().fill_g_error(err); - return FALSE; + return false; } - return TRUE; + + return true; } static void @@ -388,9 +387,6 @@ output_sexp(const Option& msg, const OutputInfo& info, const MuConfig* static bool output_json(const Option& msg, const OutputInfo& info, const MuConfig* opts, GError** err) { - if (!msg) - return true; - if (info.header) { g_print("[\n"); return true; @@ -401,6 +397,9 @@ output_json(const Option& msg, const OutputInfo& info, const MuConfig* return true; } + if (!msg) + return true; + g_print("%s%s\n", msg->to_sexp().to_json_string().c_str(), info.last ? "" : ",");