| 513 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 514 | } |
| 515 | const auto package_id = parse_ui_model_id(body_text); |
| 516 | std::lock_guard<std::mutex> lock(model_installer_mutex_); |
| 517 | if (!model_installer_) { |
| 518 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 519 | } |
| 520 | return ui_model_install_stop_response(package_id, *model_installer_); |
| 521 | } |
| 522 | |
| 523 | HttpResponse ServerState::handle_model_clean_partial(const std::string & body_text) { |
| 524 | if (!config_.ui_management) { |
| 525 | return error_response(403, "UI model cleanup is disabled", "forbidden"); |
| 526 | } |
| 527 | const auto package_id = parse_ui_model_id(body_text); |
| 528 | std::lock_guard<std::mutex> lock(model_installer_mutex_); |
| 529 | if (!model_installer_) { |
| 530 | return error_response(403, "UI model cleanup is disabled", "forbidden"); |
| 531 | } |
| 532 | return ui_model_clean_partial_response(package_id, *model_installer_); |
| 533 | } |
| 534 | |
| 535 | HttpResponse ServerState::handle_model_install_status(const HttpRequest & request) const { |
| 536 | if (!config_.ui_management) { |
| 537 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 538 | } |
| 539 | std::lock_guard<std::mutex> lock(model_installer_mutex_); |
| 540 | if (!model_installer_) { |
| 541 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 542 | } |
| 543 | return ui_model_install_status_response(request, *model_installer_); |
| 544 | } |
| 545 | |
| 546 | HttpResponse ServerState::handle_model_package_sizes() { |
| 547 | if (!config_.ui_management) { |
| 548 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 549 | } |
| 550 | std::lock_guard<std::mutex> lock(model_installer_mutex_); |
| 551 | if (!model_installer_) { |
| 552 | return error_response(403, "UI model installation is disabled", "forbidden"); |
| 553 | } |
| 554 | return ui_model_package_sizes_response(*model_installer_); |
| 555 | } |
| 556 | |
| 557 | HttpResponse ServerState::handle_models_root_get() const { |
| 558 | if (!config_.ui_management) { |
| 559 | return error_response(403, "UI model management is disabled", "forbidden"); |
| 560 | } |
| 561 | std::lock_guard<std::mutex> lock(model_installer_mutex_); |
| 562 | if (!model_installer_) { |
| 563 | return error_response(403, "UI model management is disabled", "forbidden"); |
| 564 | } |
| 565 | return ui_models_root_response(models_root_, default_models_root_); |
| 566 | } |
| 567 | |
| 568 | HttpResponse ServerState::handle_models_root_set(const std::string & body_text) { |
| 569 | if (!config_.ui_management) { |
| 570 | return error_response(403, "UI model management is disabled", "forbidden"); |
| 571 | } |
| 572 | const auto body = engine::io::json::parse(body_text); |
nothing calls this directly
no test coverage detected