partial support for remove

This commit is contained in:
2025-09-15 12:25:25 -05:00
parent 75ac2199e9
commit 1f01a43dd5
3 changed files with 22 additions and 1 deletions

View File

@@ -24,7 +24,6 @@
#include "cli/common.hpp"
#include "utils/string.hpp"
#include "utils/time.hpp"
namespace repertory::cli::actions {

View File

@@ -83,6 +83,9 @@ private:
static void handle_get_available_locations(httplib::Response &res);
void handle_del_remove_mount(const httplib::Request &req,
httplib::Response &res);
void handle_get_mount(const httplib::Request &req,
httplib::Response &res) const;

View File

@@ -207,6 +207,10 @@ ui_server::ui_server(mgmt_app_config *config)
: http_error_codes::internal_error;
});
server_.Delete("/api/v1/remove_mount", [this](auto &&req, auto &&res) {
handle_del_remove_mount(req, res);
});
server_.Get("/api/v1/locations", [](auto && /* req */, auto &&res) {
handle_get_available_locations(res);
});
@@ -339,6 +343,21 @@ void ui_server::generate_config(provider_type prov, std::string_view name,
}
}
void ui_server::handle_del_remove_mount(const httplib::Request &req,
httplib::Response &res) {
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;
}
auto lines = launch_process(prov, name, {"-rp", "-f"}, false);
res.status = lines.at(0U) == "0" ? http_error_codes::ok
: http_error_codes::internal_error;
}
void ui_server::handle_put_mount_auto_start(const httplib::Request &req,
httplib::Response &res) const {
auto prov = provider_type_from_string(req.get_param_value("type"));