update
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2ff16230d1
commit
ce1a3c416c
@ -144,7 +144,7 @@ void handlers::handle_get_mount(auto &&req, auto &&res) const {
|
|||||||
|
|
||||||
auto prov = provider_type_from_string(req.get_param_value("type"));
|
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||||
|
|
||||||
auto lines = handlers::read_process(prov, req.get_param_value("name"), "-dc");
|
auto lines = launch_process(prov, req.get_param_value("name"), "-dc");
|
||||||
|
|
||||||
if (lines.at(0U) != "0") {
|
if (lines.at(0U) != "0") {
|
||||||
throw utils::error::create_exception(function_name, {
|
throw utils::error::create_exception(function_name, {
|
||||||
@ -238,7 +238,7 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lines = handlers::read_process(prov, name, "-status");
|
auto lines = launch_process(prov, name, "-status");
|
||||||
|
|
||||||
nlohmann::json result(
|
nlohmann::json result(
|
||||||
nlohmann::json::parse(utils::string::join(lines, '\n')).at(status_name));
|
nlohmann::json::parse(utils::string::join(lines, '\n')).at(status_name));
|
||||||
@ -260,9 +260,9 @@ void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
|||||||
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
||||||
|
|
||||||
if (unmount) {
|
if (unmount) {
|
||||||
read_process(prov, name, "-unmount");
|
launch_process(prov, name, "-unmount");
|
||||||
} else {
|
} else {
|
||||||
read_process(prov, name, fmt::format(R"("{}")", location));
|
launch_process(prov, name, fmt::format(R"("{}")", location), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = http_error_codes::ok;
|
res.status = http_error_codes::ok;
|
||||||
@ -275,16 +275,16 @@ void handlers::handle_put_set_value_by_name(auto &&req, auto &&res) {
|
|||||||
auto value = req.get_param_value("value");
|
auto value = req.get_param_value("value");
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
read_process(prov, name, fmt::format(R"(-set {} "{}")", key, value));
|
launch_process(prov, name, fmt::format(R"(-set {} "{}")", key, value));
|
||||||
#else //! defined(_WIN32)
|
#else //! defined(_WIN32)
|
||||||
read_process(prov, name, fmt::format("-set {} '{}'", key, value));
|
launch_process(prov, name, fmt::format("-set {} '{}'", key, value));
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
res.status = http_error_codes::ok;
|
res.status = http_error_codes::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handlers::read_process(provider_type prov, std::string_view name,
|
auto handlers::launch_process(provider_type prov, std::string_view name,
|
||||||
std::string_view command) const
|
std::string_view command, bool background) const
|
||||||
-> std::vector<std::string> {
|
-> std::vector<std::string> {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
@ -319,6 +319,10 @@ auto handlers::read_process(provider_type prov, std::string_view name,
|
|||||||
auto cmd_line =
|
auto cmd_line =
|
||||||
fmt::format(R"({} {} {})", repertory_binary_, str_type, command);
|
fmt::format(R"({} {} {})", repertory_binary_, str_type, command);
|
||||||
|
|
||||||
|
if (background) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
auto *pipe = popen(cmd_line.c_str(), "r");
|
auto *pipe = popen(cmd_line.c_str(), "r");
|
||||||
if (pipe == nullptr) {
|
if (pipe == nullptr) {
|
||||||
throw utils::error::create_exception(function_name,
|
throw utils::error::create_exception(function_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user