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:
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user