fix: add bytes dependency and fix stream type mismatches

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-25 18:46:15 -03:00
parent a814f60f32
commit 81307bfe19
2 changed files with 9 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ use axum::{
};
use log::warn;
use std::collections::HashMap;
use bytes::Bytes;
use crate::services::async_item_service::AsyncItemService;
use crate::services::error::CoreError;
@@ -240,13 +241,14 @@ async fn stream_item_content(
buffered_file.seek(std::io::SeekFrom::Start(offset)).await?;
}
// Create a reader stream with optional length limit
// Create a reader stream with optional length limit
let stream = if length > 0 {
// Limit the stream to the specified length
ReaderStream::new(buffered_file.take(length))
Box::pin(ReaderStream::new(buffered_file.take(length))) as std::pin::Pin<Box<dyn tokio_stream::Stream<Item = Result<Bytes, std::io::Error>> + Send>>
} else {
// Stream the entire file from the offset
ReaderStream::new(buffered_file)
Box::pin(ReaderStream::new(buffered_file)) as std::pin::Pin<Box<dyn tokio_stream::Stream<Item = Result<Bytes, std::io::Error>> + Send>>
};
Ok((stream, mime_type))