refactor
This commit is contained in:
parent
083406a85d
commit
4a59917d23
@ -195,9 +195,9 @@ void handlers::handle_get_mount_list(auto &&res) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handlers::handle_get_mount_location(auto &&req, auto &&res) const {
|
void handlers::handle_get_mount_location(auto &&req, auto &&res) const {
|
||||||
auto type = req.get_param_value("type");
|
|
||||||
auto prov = provider_type_from_string(type);
|
|
||||||
auto name = req.get_param_value("name");
|
auto name = req.get_param_value("name");
|
||||||
|
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||||
|
|
||||||
res.set_content(
|
res.set_content(
|
||||||
nlohmann::json({
|
nlohmann::json({
|
||||||
{"Location", config_->get_mount_location(prov, name)},
|
{"Location", config_->get_mount_location(prov, name)},
|
||||||
@ -210,10 +210,10 @@ void handlers::handle_get_mount_location(auto &&req, auto &&res) const {
|
|||||||
void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
auto type = req.get_param_value("type");
|
|
||||||
auto prov = provider_type_from_string(type);
|
|
||||||
auto status_name = app_config::get_provider_display_name(prov);
|
|
||||||
auto name = req.get_param_value("name");
|
auto name = req.get_param_value("name");
|
||||||
|
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||||
|
|
||||||
|
auto status_name = app_config::get_provider_display_name(prov);
|
||||||
|
|
||||||
switch (prov) {
|
switch (prov) {
|
||||||
case provider_type::encrypt:
|
case provider_type::encrypt:
|
||||||
@ -230,21 +230,23 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw utils::error::create_exception(
|
throw utils::error::create_exception(function_name,
|
||||||
function_name, {
|
{
|
||||||
fmt::format("`{}` is not supported", name),
|
"provider is not supported",
|
||||||
});
|
provider_type_to_string(prov),
|
||||||
|
name,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lines = handlers::read_process(prov, name, "-status");
|
auto lines = handlers::read_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));
|
||||||
if (result["Location"].get<std::string>().empty()) {
|
if (result.at("Location").get<std::string>().empty()) {
|
||||||
result["Location"] = config_->get_mount_location(prov, name);
|
result.at("Location") = config_->get_mount_location(prov, name);
|
||||||
} else {
|
} else if (result.at("Active").get<bool>()) {
|
||||||
config_->set_mount_location(prov, name,
|
config_->set_mount_location(prov, name,
|
||||||
result["Location"].get<std::string>());
|
result.at("Location").get<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
res.set_content(result.dump(), "application/json");
|
res.set_content(result.dump(), "application/json");
|
||||||
@ -252,11 +254,10 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
||||||
auto type = req.get_param_value("type");
|
|
||||||
auto name = req.get_param_value("name");
|
|
||||||
auto location = utils::path::absolute(req.get_param_value("location"));
|
auto location = utils::path::absolute(req.get_param_value("location"));
|
||||||
|
auto name = req.get_param_value("name");
|
||||||
|
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||||
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
|
||||||
auto prov = provider_type_from_string(type);
|
|
||||||
|
|
||||||
if (unmount) {
|
if (unmount) {
|
||||||
read_process(prov, name, "-unmount");
|
read_process(prov, name, "-unmount");
|
||||||
@ -268,11 +269,9 @@ void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handlers::handle_put_set_value_by_name(auto &&req, auto &&res) {
|
void handlers::handle_put_set_value_by_name(auto &&req, auto &&res) {
|
||||||
auto type = req.get_param_value("type");
|
|
||||||
auto name = req.get_param_value("name");
|
|
||||||
auto prov = provider_type_from_string(type);
|
|
||||||
|
|
||||||
auto key = req.get_param_value("key");
|
auto key = req.get_param_value("key");
|
||||||
|
auto name = req.get_param_value("name");
|
||||||
|
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||||
auto value = req.get_param_value("value");
|
auto value = req.get_param_value("value");
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user