diff --git a/app/api/routers/config.py b/app/api/routers/config.py index 9e60568..87e3cb5 100644 --- a/app/api/routers/config.py +++ b/app/api/routers/config.py @@ -137,7 +137,7 @@ async def update_cell_data_mysql_config(config: dict[str, Any] = Body(...)): @router.post("/api/config/cell-data/remote/test") -async def test_cell_data_remote_connection(config: dict[str, Any] | None = Body(None)): +def test_cell_data_remote_connection(config: dict[str, Any] | None = Body(None)): try: remote_config = RemoteDataConfig.from_dict(config) if config else state.current_config().cell_data.remote_data RemoteDataDownloader(remote_config).test_connection() @@ -147,7 +147,7 @@ async def test_cell_data_remote_connection(config: dict[str, Any] | None = Body( @router.post("/api/config/cell-data/mysql/test") -async def test_cell_data_mysql_connection(config: dict[str, Any] | None = Body(None)): +def test_cell_data_mysql_connection(config: dict[str, Any] | None = Body(None)): mysql_config = MySQLConfig.from_dict(config, default_dbname="celldata") if config else state.current_config().cell_data.mysql return _test_mysql_config(mysql_config) diff --git a/app/api/routers/remote.py b/app/api/routers/remote.py index bb515e1..e6ed2b9 100644 --- a/app/api/routers/remote.py +++ b/app/api/routers/remote.py @@ -25,7 +25,7 @@ router = APIRouter(tags=["remote"]) @router.post("/api/remote/test") -async def test_remote_connection(config: dict[str, Any] | None = Body(None)): +def test_remote_connection(config: dict[str, Any] | None = Body(None)): app_config = state.current_config() try: if app_config.source_type == "metrix": diff --git a/docs/project_context.md b/docs/project_context.md index 7d8b5a3..3667943 100644 --- a/docs/project_context.md +++ b/docs/project_context.md @@ -841,3 +841,8 @@ - 新增 `app.utils.files.safe_relative_path()`,容量数据上传和 CellData 本地上传保存文件前统一过滤空片段、`.` 与 `..`,避免客户端文件名或 `webkitRelativePath` 中的路径穿越片段写出任务工作目录,同时保留合法的文件夹层级。 - 验证:`safe_relative_path` 典型路径断言通过;`python -m compileall -q app` 通过;`frontend` `npm run build` 通过;构建产物已清理。 + +## 2026-06-25:连接测试接口改为线程池执行 + +- `/api/remote/test`、`/api/config/cell-data/remote/test`、`/api/config/cell-data/mysql/test` 改为同步路由函数,保持响应结构不变,但让 FastAPI 在线程池中执行 FTP/SFTP、Metrix 平台 HTTP 与 MySQL 连接测试,避免慢连接或超时阻塞事件循环。 +- 验证:`.venv\Scripts\python.exe -m compileall -q app` 通过;`frontend` `npm run build` 通过;构建产物已清理。