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

@@ -2,6 +2,7 @@ use crate::services::error::CoreError;
use crate::services::item_service::ItemService;
use crate::services::types::{ItemWithContent, ItemWithMeta};
use crate::common::is_binary::is_binary;
use bytes::Bytes;
use rusqlite::Connection;
use std::collections::HashMap;
use std::path::PathBuf;
@@ -15,7 +16,7 @@ use tokio_util::io::ReaderStream;
/// on a dedicated thread pool, preventing them from blocking the async runtime.
#[allow(dead_code)]
pub struct AsyncItemService {
data_path: PathBuf,
pub data_dir: PathBuf,
db: Arc<Mutex<Connection>>,
}
@@ -90,13 +91,14 @@ impl AsyncItemService {
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))