diff --git a/scripts/ingest_folder.py b/scripts/ingest_folder.py index 220e7df..09f43a5 100644 --- a/scripts/ingest_folder.py +++ b/scripts/ingest_folder.py @@ -28,7 +28,14 @@ def main(path: Path, recursive: bool, force: bool, mode: str) -> None: run_id = uuid.uuid4() discovered = queued = dups = invalid = 0 - for record in discover_documents(path, recursive=recursive, force=force): + # Materialize generator first: scanner's per-document session_scope only + # commits when the generator advances past the yield. Inline mode invokes + # the pipeline (which opens a fresh session) before that commit happens, + # so the document row is invisible. List() drains the generator end to end, + # forcing all commits before any processing. + records = list(discover_documents(path, recursive=recursive, force=force)) + + for record in records: discovered += 1 if record.duplicate and not force: dups += 1