mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-16 03:28:27 +00:00
Improved PDFium initialization and error handling logic (#649)
This commit is contained in:
1 parent
5ea92c9ced
commit
0e14a3cb58
3 files changed
+39
-11
No files matched your search
@@ -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)))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user