mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
cleanup_unused_content decides whether to delete a deduplicated blob by running a Tantivy Count of envelopes referencing each content_hash. The searcher it used reflected only the committed index state at the time it was built, so an envelope that shared a content hash but was still sitting uncommitted in the IndexWriter buffer (for example added by the background ingest task before the delete operation acquired the writer lock) was invisible to the count. The count read 0 and a still-referenced blob was deleted, permanently 404ing that envelope's download-message. Pass the locked IndexWriter into cleanup_unused_content and fatal_commit it immediately before creating the searcher. create_searcher already reloads the reader, so the Count is now evaluated against a fully committed, freshly-reloaded index state. The barrier is local to the GC path and self-contained, independent of what the caller committed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>