From d4718bf9dca8512c153247dc4d618df1bcd019b0 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 25 May 2026 23:48:09 +0800 Subject: [PATCH] fix: expose rust acceleration availability --- app/api/endpoints/system.py | 1 + skills/moviepilot-api/SKILL.md | 2 +- tests/test_system_nettest.py | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/api/endpoints/system.py b/app/api/endpoints/system.py index f6124da4..5b0b0367 100644 --- a/app/api/endpoints/system.py +++ b/app/api/endpoints/system.py @@ -515,6 +515,7 @@ async def get_env_setting(_: User = Depends(get_current_active_user_async)): "AUTH_VERSION": SitesHelper().auth_version, "INDEXER_VERSION": SitesHelper().indexer_version, "FRONTEND_VERSION": SystemChain().get_frontend_version(), + "RUST_ACCEL_AVAILABLE": rust_accel.is_available(), "RUST_ACCEL_ENABLED": rust_accel.is_enabled(), } ) diff --git a/skills/moviepilot-api/SKILL.md b/skills/moviepilot-api/SKILL.md index ecb96577..2462a98f 100644 --- a/skills/moviepilot-api/SKILL.md +++ b/skills/moviepilot-api/SKILL.md @@ -314,7 +314,7 @@ All endpoints are under the base URL `{MP_HOST}`. Path parameters are shown as ` | Method | Path | Description | |--------|------|-------------| -| GET | `/api/v1/system/env` | Get system configuration | +| GET | `/api/v1/system/env` | Get system configuration, including runtime versions and Rust acceleration availability/enabled status | | POST | `/api/v1/system/env` | Update system configuration. Body: JSON object | | GET | `/api/v1/system/setting/{key}` | Get system setting | | POST | `/api/v1/system/setting/{key}` | Update system setting | diff --git a/tests/test_system_nettest.py b/tests/test_system_nettest.py index 31b2b2ac..4b7a9f6f 100644 --- a/tests/test_system_nettest.py +++ b/tests/test_system_nettest.py @@ -82,12 +82,25 @@ _stub_module( ) _stub_module("app.utils.crypto", HashUtils=_Dummy) _stub_module("app.utils.http", RequestUtils=_Dummy, AsyncRequestUtils=_Dummy) -_stub_module("version", APP_VERSION="test") +_stub_module("version", APP_VERSION="test", FRONTEND_VERSION="frontend-test") from app.api.endpoints import system as system_endpoint class NettestSecurityTest(unittest.TestCase): + def test_get_env_setting_reports_rust_available_and_enabled_separately(self): + """ + 系统配置接口应分别返回 Rust 扩展可用性和当前实际启用状态。 + """ + with patch.object(system_endpoint.rust_accel, "is_available", return_value=True), patch.object( + system_endpoint.rust_accel, "is_enabled", return_value=False + ): + resp = asyncio.run(system_endpoint.get_env_setting(_="token")) + + self.assertTrue(resp.success) + self.assertTrue(resp.data["RUST_ACCEL_AVAILABLE"]) + self.assertFalse(resp.data["RUST_ACCEL_ENABLED"]) + def test_fetch_image_allows_signed_private_url(self): """ 服务端签名过的私网图片 URL 可以继续代理,保证前端封面显示。