mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-10 22:32:16 +02:00
fix(github): commit failed status immediately
This commit is contained in:
parent
f085ac59e5
commit
f5dd8f3985
1 changed files with 6 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ Implements 2-phase document status updates for real-time UI feedback:
|
||||||
- Phase 2: Process each document: pending → processing → ready/failed
|
- Phase 2: Process each document: pending → processing → ready/failed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import time
|
import time
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
|
|
@ -413,10 +414,15 @@ async def index_github_repos(
|
||||||
try:
|
try:
|
||||||
document.status = DocumentStatus.failed(str(repo_err))
|
document.status = DocumentStatus.failed(str(repo_err))
|
||||||
document.updated_at = get_current_timestamp()
|
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:
|
except Exception as status_error:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"Failed to update document status to failed: {status_error}"
|
f"Failed to update document status to failed: {status_error}"
|
||||||
)
|
)
|
||||||
|
with contextlib.suppress(Exception):
|
||||||
|
await session.rollback()
|
||||||
errors.append(f"Failed processing {repo_full_name}: {repo_err}")
|
errors.append(f"Failed processing {repo_full_name}: {repo_err}")
|
||||||
documents_failed += 1
|
documents_failed += 1
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue