feat(daemon): uninstall manifest-owned files on request
This commit is contained in:
1 parent
2c602fc3e7
commit
716c049cff
8 files changed
+63
-6
No files matched your search
@@ -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()) {
|
||||
|
||||
Reference in new issue
Block a user