This commit is contained in:
2026-05-30 00:15:16 +05:00
parent d3afd698b6
commit 43dee9f796
5 changed files with 58 additions and 2 deletions
+15
View File
@@ -280,3 +280,18 @@ async def delete_camera(cam_id: str, request: Request) -> dict:
await runtime.supervisor.remove_camera(cam_id)
await go2rtc.remove_camera_streams(runtime.config, cam_id)
return {"ok": True}
@router.post("/clear")
async def clear_cameras(request: Request) -> dict:
"""Удаляет ВСЕ камеры: чистит cameras.yaml, останавливает запись и потоки go2rtc.
Архив (nvr.db + файлы .mp4) НЕ трогает — очищается только список камер."""
require_role(request, "admin")
ids = [c.id for c in runtime.config.cameras]
runtime.config.cameras = []
save_config(runtime.config)
for cam_id in ids:
await runtime.supervisor.remove_camera(cam_id)
await go2rtc.remove_camera_streams(runtime.config, cam_id)
return {"ok": True, "removed": len(ids)}