From 699b9322eebf5f6a271be9ca87d18a08351d5c8d Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Thu, 16 Jul 2026 13:50:35 -0400 Subject: [PATCH] feat(ingest): ensure session rollback on ingestion error and log mention count --- python/ebook_search/ingest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/ebook_search/ingest.py b/python/ebook_search/ingest.py index 0413a91..88c2865 100644 --- a/python/ebook_search/ingest.py +++ b/python/ebook_search/ingest.py @@ -159,13 +159,14 @@ async def ingest_file(session: AsyncSession, path: Path | AsyncPath, config: Ebo await session.flush() chunk_index = add_chapter_chunks(session, source, chapter, parsed_chapter, chunk_index, config) - await session.commit() mention_count = await index_chunk_phrase_mentions_for_book(session, source.id, config) + await session.commit() logger.info( f"ebook_ingest_file_complete {source.id=} {resolved_path=} chapters={len(parsed.chapters)} {chunk_index=} " f"{mention_count=}" ) except Exception: + await session.rollback() logger.exception(f"ebook_ingest_file_error {path=}") return False else: