mu-maildir: use the new run_command0

And fix some docstrings.
This commit is contained in:
Dirk-Jan C. Binnema
2023-09-19 23:42:23 +03:00
parent b771fd6394
commit 8ba153067b
2 changed files with 10 additions and 20 deletions

View File

@ -293,19 +293,8 @@ msg_move_g_file(const std::string& src, const std::string& dst)
G_GNUC_UNUSED static Mu::Result<void>
msg_move_mv_file(const std::string& src, const std::string& dst)
{
const auto cmdline{mu_format("/bin/mv {} {}",
to_string_gchar(g_shell_quote(src.c_str())),
to_string_gchar(g_shell_quote(dst.c_str())))};
GError *err{};
int wait_status{};
mu_debug("{}", cmdline);
if (!g_spawn_command_line_sync(cmdline.c_str(), {}, {}, &wait_status, &err))
return Err(Error::Code::File, &err, "error moving {} -> {}", src, dst);
else if (auto&& res{WEXITSTATUS(wait_status)}; res != 0)
return Err(Error::Code::File, "error moving {} -> {}; err={}",
src, dst, res);
if (auto res{run_command0({"/bin/mv", src, dst})}; !res)
return Err(Error::Code::File, "error moving {}->{}; err={}", src, dst, res.error());
else
return Ok();
}
@ -424,7 +413,7 @@ check_determine_target_params (const std::string& old_path,
if (any_of(newflags & Flags::New) && newflags != Flags::New)
return Err(Error{Error::Code::File,
"if ::New is specified, it must be the only flag"});
"if the New flag is specified, it must be the only flag"});
return Ok();
}
@ -436,6 +425,8 @@ Mu::maildir_determine_target(const std::string& old_path,
Flags newflags,
bool new_name)
{
newflags = flags_mail_dir_file(newflags); // filter out irrelevant flags.
/* sanity checks */
if (const auto checked{check_determine_target_params(
old_path, root_maildir_path, target_maildir, newflags)}; !checked)