feat(daemon): uninstall manifest-owned files on request
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 8s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 03:18:42 +03:00
1 parent 2c602fc3e7
commit 716c049cff
8 files changed
+63 -6

No files matched your search

+20
View File
@@ -1884,6 +1884,26 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "ide_configs") {
return {ide_configs_project(options), false};
}
if (*name == "uninstall") {
const auto entry = object->find("prefix");
if (entry == object->end()) {
return {error_response("uninstall requires \"prefix\""), false};
}
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty() || value->size() > 4096) {
return {error_response("\"prefix\" must be a bounded non-empty string"), false};
}
auto removed = Install::uninstall_prefix(*value);
if (!removed) {
return {error_response(std::format("uninstall: {}", removed.error().format())), false};
}
JsonValue::Object object;
object.emplace("ok", JsonValue{true});
object.emplace("op", JsonValue{std::string{"uninstall"}});
object.emplace("prefix", JsonValue{*value});
object.emplace("removed", JsonValue{static_cast<std::int64_t>(*removed)});
return {serialize_response(JsonValue{std::move(object)}), false};
}
if (*name == "pack") {
std::string output_name{"package.tar"};
if (const auto entry = object->find("output"); entry != object->end()) {
+12
View File
@@ -1616,6 +1616,13 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
request_json = opts.pack_output_arg ? std::format(R"({{"op":"pack","output":{}}})",
Util::json_quote(*opts.pack_output_arg))
: R"({"op":"pack"})";
} else if (sub == "uninstall") {
if (!opts.prefix_arg || opts.prefix_arg->empty()) {
std::cerr << "vbs daemon uninstall: --prefix is required\n";
return 2;
}
request_json =
std::format(R"({{"op":"uninstall","prefix":{}}})", Util::json_quote(*opts.prefix_arg));
} else if (sub == "install") {
if (!opts.prefix_arg || opts.prefix_arg->empty()) {
std::cerr << "vbs daemon install: --prefix is required\n";
@@ -2782,6 +2789,11 @@ int main(int argc, char **argv) {
daemon_install_cmd.option("--prefix", "", "Install prefix (required)", daemon_opts.prefix_arg)
.option_default("--package-version", "", "Exported package version",
daemon_opts.package_version_arg, "0.1.0");
auto &daemon_uninstall_cmd =
daemon_cmd.subcommand("uninstall", "Remove VBS-owned installed files via the daemon");
configure_daemon_common(daemon_uninstall_cmd);
daemon_uninstall_cmd.option("--prefix", "", "Install prefix (required)",
daemon_opts.prefix_arg);
auto &daemon_target_cmd =
daemon_cmd.subcommand("target", "Target metadata served by the daemon");
auto &daemon_target_info_cmd = daemon_target_cmd.subcommand(