Improved PDFium initialization and error handling logic (#649)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-02-01 19:51:12 +01:00
1 parent 5ea92c9ced
commit 0e14a3cb58
3 files changed
+39 -11

No files matched your search

+8 -2
View File
@@ -246,7 +246,13 @@ async fn stream_pdf(file_path: &str) -> Result<ChunkStream> {
let (tx, rx) = mpsc::channel(10);
tokio::task::spawn_blocking(move || {
let pdfium = Pdfium::ai_studio_init();
let pdfium = match Pdfium::ai_studio_init() {
Ok(pdfium) => pdfium,
Err(e) => {
let _ = tx.blocking_send(Err(e));
return;
}
};
let doc = match pdfium.load_pdf_from_file(&path, None) {
Ok(document) => document,
Err(e) => {
@@ -464,4 +470,4 @@ async fn stream_pptx(file_path: &str, extract_images: bool) -> Result<ChunkStrea
});
Ok(Box::pin(ReceiverStream::new(rx)))
}
}