From 2496679165bd350b88f3373e08cd4ceb5a24f132 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 24 Mar 2025 13:00:55 -0500 Subject: [PATCH] added clear mount location --- repertory/repertory/include/ui/handlers.hpp | 3 +++ repertory/repertory/src/ui/handlers.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/repertory/repertory/include/ui/handlers.hpp b/repertory/repertory/include/ui/handlers.hpp index 27d07c0a..e49bb0f8 100644 --- a/repertory/repertory/include/ui/handlers.hpp +++ b/repertory/repertory/include/ui/handlers.hpp @@ -74,6 +74,9 @@ private: [[nodiscard]] auto data_directory_exists(provider_type prov, std::string_view name) const -> bool; + void handle_delete_mount_location(const httplib::Request &req, + httplib::Response &res) const; + void handle_get_available_locations(httplib::Response &res) const; void handle_get_mount(const httplib::Request &req, diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index c8192525..3fd2148a 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -168,6 +168,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server) : http_error_codes::internal_error; }); + server->Delete("/api/v1/mount_location", [this](auto &&req, auto &&res) { + handle_delete_mount_location(req, res); + }); + server->Get("/api/v1/locations", [this](auto && /* req */, auto &&res) { handle_get_available_locations(res); }); @@ -298,6 +302,22 @@ auto handlers::data_directory_exists(provider_type prov, return ret; } +void handlers::handle_delete_mount_location(const httplib::Request &req, + httplib::Response &res) const { + REPERTORY_USES_FUNCTION_NAME(); + + auto prov = provider_type_from_string(req.get_param_value("type")); + auto name = req.get_param_value("name"); + + if (not data_directory_exists(prov, name)) { + res.status = http_error_codes::not_found; + return; + } + + config_->set_mount_location(prov, name, ""); + res.status = http_error_codes::ok; +} + void handlers::handle_get_available_locations(httplib::Response &res) const { #if defined(_WIN32) constexpr const std::array letters{