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 {
|
||||
auto type = req.get_param_value("type");
|
||||
auto prov = provider_type_from_string(type);
|
||||
auto name = req.get_param_value("name");
|
||||
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||
|
||||
res.set_content(
|
||||
nlohmann::json({
|
||||
{"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 {
|
||||
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 prov = provider_type_from_string(req.get_param_value("type"));
|
||||
|
||||
auto status_name = app_config::get_provider_display_name(prov);
|
||||
|
||||
switch (prov) {
|
||||
case provider_type::encrypt:
|
||||
@ -230,9 +230,11 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw utils::error::create_exception(
|
||||
function_name, {
|
||||
fmt::format("`{}` is not supported", name),
|
||||
throw utils::error::create_exception(function_name,
|
||||
{
|
||||
"provider is not supported",
|
||||
provider_type_to_string(prov),
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
@ -240,11 +242,11 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
|
||||
|
||||
nlohmann::json result(
|
||||
nlohmann::json::parse(utils::string::join(lines, '\n')).at(status_name));
|
||||
if (result["Location"].get<std::string>().empty()) {
|
||||
result["Location"] = config_->get_mount_location(prov, name);
|
||||
} else {
|
||||
if (result.at("Location").get<std::string>().empty()) {
|
||||
result.at("Location") = config_->get_mount_location(prov, name);
|
||||
} else if (result.at("Active").get<bool>()) {
|
||||
config_->set_mount_location(prov, name,
|
||||
result["Location"].get<std::string>());
|
||||
result.at("Location").get<std::string>());
|
||||
}
|
||||
|
||||
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 {
|
||||
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 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 prov = provider_type_from_string(type);
|
||||
|
||||
if (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) {
|
||||
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 name = req.get_param_value("name");
|
||||
auto prov = provider_type_from_string(req.get_param_value("type"));
|
||||
auto value = req.get_param_value("value");
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user