Harden DInSAR and SBAS production edges

This commit is contained in:
2026-06-02 15:11:07 +08:00
parent 48f672241f
commit b931e8db53
6 changed files with 88 additions and 21 deletions
+2
View File
@@ -78,6 +78,8 @@ HIGH_RISK_WRITE_PATH_PREFIXES = (
"/api/scan-data",
"/api/scan-dinsar-results",
"/api/dinsar-results/",
"/api/dinsar-production",
"/api/sbas-insar-production",
"/api/ai/",
"/api/idl/launch-workbench",
"/api/idl/worker/",
+2 -13
View File
@@ -106,19 +106,6 @@ def _is_postgresql_session(db: AsyncSession) -> bool:
return (dialect_name or "").lower() == "postgresql"
except Exception:
return False
"""
try:
scan_dirs = list(request.results_directories) if request else []
if not scan_dirs:
scan_dirs = _get_default_dinsar_scan_dirs()
if not scan_dirs:
raise HTTPException(status_code=400, detail="未提供结果目录,且 MONITOR_DINSAR_DIRS 未配置。")
bind = db.get_bind()
dialect_name = getattr(getattr(bind, "dialect", None), "name", "")
return (dialect_name or "").lower() == "postgresql"
except Exception:
return False
"""
async def _apply_list_query_statement_timeout(db: AsyncSession) -> None:
@@ -249,6 +236,8 @@ async def scan_dinsar_results_endpoint(
)
await db.commit()
return {"message": "D-InSAR 统一扫描任务已进入队列", "task_id": task_id}
except HTTPException:
raise
except ValueError as e:
raise HTTPException(status_code=409, detail=str(e))
except Exception as e:
-6
View File
@@ -232,12 +232,6 @@ async def submit_run(
status_code=400,
detail=f"PyINT 输入资产预检未通过: {detail or '请先修复阻塞项。'}",
)
if not pyint_preview.get("allow_submit"):
detail = summarize_preview_blockers(pyint_preview)
raise HTTPException(
status_code=400,
detail=f"PyINT 输入资产预检未通过: {detail or '请先修复阻塞项。'}",
)
payload = {
"engine_code": req.engine_code,
+3 -1
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import mimetypes
import os
from typing import List, Optional
@@ -258,4 +259,5 @@ async def get_dinsar_product_preview(
preview_path = str(detail.get("preview_path") or "").strip()
if not preview_path or not os.path.isfile(preview_path):
raise HTTPException(status_code=404, detail="Preview not found")
return FileResponse(preview_path, media_type="image/webp")
media_type = mimetypes.guess_type(preview_path)[0] or "application/octet-stream"
return FileResponse(preview_path, media_type=media_type)