fix(bookstack): commit failed status immediately

This commit is contained in:
CREDO23 2026-06-10 00:10:52 +02:00
parent 45438249b6
commit 8191118eb4

View file

@ -6,6 +6,7 @@ Implements 2-phase document status updates for real-time UI feedback:
- Phase 2: Process each page: pending processing ready/failed
"""
import contextlib
import time
from collections.abc import Awaitable, Callable
from datetime import datetime
@ -432,10 +433,15 @@ async def index_bookstack_pages(
try:
document.status = DocumentStatus.failed(str(e))
document.updated_at = get_current_timestamp()
# Commit now so the failed status survives a later rollback or
# crash; otherwise the doc stays stuck in pending/processing.
await session.commit()
except Exception as status_error:
logger.error(
f"Failed to update document status to failed: {status_error}"
)
with contextlib.suppress(Exception):
await session.rollback()
skipped_pages.append(
f"{item.get('page_name', 'Unknown')} (processing error)"
)