diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index 392d8875..c6f961aa 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -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,21 +230,23 @@ 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, + }); } auto lines = handlers::read_process(prov, name, "-status"); nlohmann::json result( nlohmann::json::parse(utils::string::join(lines, '\n')).at(status_name)); - if (result["Location"].get().empty()) { - result["Location"] = config_->get_mount_location(prov, name); - } else { + if (result.at("Location").get().empty()) { + result.at("Location") = config_->get_mount_location(prov, name); + } else if (result.at("Active").get()) { config_->set_mount_location(prov, name, - result["Location"].get()); + result.at("Location").get()); } 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)