Formatting

This commit is contained in:
Thorsten Sommer 2025-06-30 20:32:49 +02:00
parent d8e8d8b66c
commit f7c3011678
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -149,33 +149,40 @@ async fn stream_data(file_path: &str) -> Result<ChunkStream> {
_ => match fmt.kind() { _ => match fmt.kind() {
Kind::Document => match fmt { Kind::Document => match fmt {
FileFormat::PortableDocumentFormat => stream_pdf(file_path).await?, FileFormat::PortableDocumentFormat => stream_pdf(file_path).await?,
FileFormat::MicrosoftWordDocument => { FileFormat::MicrosoftWordDocument => {
convert_with_pandoc(file_path, "docx", TO_MARKDOWN).await? convert_with_pandoc(file_path, "docx", TO_MARKDOWN).await?
} },
FileFormat::OfficeOpenXmlDocument => { FileFormat::OfficeOpenXmlDocument => {
convert_with_pandoc(file_path, fmt.extension(), TO_MARKDOWN).await? convert_with_pandoc(file_path, fmt.extension(), TO_MARKDOWN).await?
} },
_ => stream_text_file(file_path).await?, _ => stream_text_file(file_path).await?,
}, },
Kind::Ebook => return Err("Ebooks not yet supported".into()), Kind::Ebook => return Err("Ebooks not yet supported".into()),
Kind::Image => chunk_image(file_path).await?, Kind::Image => chunk_image(file_path).await?,
Kind::Other => match fmt { Kind::Other => match fmt {
FileFormat::HypertextMarkupLanguage => { FileFormat::HypertextMarkupLanguage => {
convert_with_pandoc(file_path, fmt.extension(), TO_MARKDOWN).await? convert_with_pandoc(file_path, fmt.extension(), TO_MARKDOWN).await?
} },
_ => stream_text_file(file_path).await?, _ => stream_text_file(file_path).await?,
}, },
Kind::Presentation => match fmt { Kind::Presentation => match fmt {
FileFormat::OfficeOpenXmlPresentation => { FileFormat::OfficeOpenXmlPresentation => {
stream_pptx(file_path).await? stream_pptx(file_path).await?
} },
_ => stream_text_file(file_path).await?, _ => stream_text_file(file_path).await?,
}, },
Kind::Spreadsheet => stream_spreadsheet_as_csv(file_path).await?, Kind::Spreadsheet => stream_spreadsheet_as_csv(file_path).await?,
_ => stream_text_file(file_path).await?, _ => stream_text_file(file_path).await?,
}, },
}; };
@ -364,7 +371,6 @@ async fn stream_pptx(file_path: &str) -> Result<ChunkStream> {
if let Some(images) = slide.load_images_manually() { if let Some(images) = slide.load_images_manually() {
for image in images.iter() { for image in images.iter() {
let base64_data = &image.base64_content; let base64_data = &image.base64_content;
let total_length = base64_data.len(); let total_length = base64_data.len();
let mut offset = 0; let mut offset = 0;
let mut segment_index = 0; let mut segment_index = 0;