feat: Implement generation cancellation for projects, update project status handling, and mark chapters as done upon segment completion.

This commit is contained in:
2026-03-11 16:37:33 +08:00
parent 44c39f1456
commit 0d8756ebab
2 changed files with 28 additions and 5 deletions

View File

@@ -319,7 +319,7 @@ async def parse_all_chapters_endpoint(
project = crud.get_audiobook_project(db, project_id, current_user.id)
if not project:
raise HTTPException(status_code=404, detail="Project not found")
if project.status not in ("ready", "done", "error"):
if project.status not in ("ready", "generating", "done", "error"):
raise HTTPException(status_code=400, detail=f"Project must be in 'ready' state, current: {project.status}")
if not current_user.llm_api_key or not current_user.llm_base_url or not current_user.llm_model:
@@ -328,7 +328,7 @@ async def parse_all_chapters_endpoint(
from core.audiobook_service import parse_all_chapters
from core.database import SessionLocal
statuses = ("error",) if only_errors else ("pending", "error", "ready")
statuses = ("error",) if only_errors else ("pending", "error")
async def run():
async_db = SessionLocal()