fix: Resolve compilation errors with missing imports and closure moves
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -58,11 +58,11 @@ impl AsyncItemService {
|
||||
}
|
||||
|
||||
pub async fn get_item(&self, id: i64) -> Result<ItemWithMeta, CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.get_item(conn, id)).await
|
||||
self.execute_blocking(move |conn, item_service| item_service.get_item(conn, id)).await
|
||||
}
|
||||
|
||||
pub async fn get_item_content(&self, id: i64) -> Result<ItemWithContent, CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.get_item_content(conn, id)).await
|
||||
self.execute_blocking(move |conn, item_service| item_service.get_item_content(conn, id)).await
|
||||
}
|
||||
|
||||
pub async fn get_item_content_info(
|
||||
@@ -70,7 +70,7 @@ impl AsyncItemService {
|
||||
id: i64,
|
||||
filter: Option<String>,
|
||||
) -> Result<(Vec<u8>, String, bool), CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.get_item_content_info(conn, id, filter)).await
|
||||
self.execute_blocking(move |conn, item_service| item_service.get_item_content_info(conn, id, filter)).await
|
||||
}
|
||||
|
||||
pub async fn stream_item_content_by_id(
|
||||
@@ -80,7 +80,7 @@ impl AsyncItemService {
|
||||
offset: u64,
|
||||
length: u64,
|
||||
) -> Result<(std::pin::Pin<Box<dyn tokio_stream::Stream<Item = Result<tokio_util::bytes::Bytes, std::io::Error>> + Send>>, String), CoreError> {
|
||||
let content = self.execute_blocking(|conn, item_service| {
|
||||
let content = self.execute_blocking(move |conn, item_service| {
|
||||
let item_with_content = item_service.get_item_content(conn, item_id)?;
|
||||
Ok::<_, CoreError>(item_with_content.content)
|
||||
}).await?;
|
||||
@@ -177,6 +177,8 @@ impl AsyncItemService {
|
||||
let reader = {
|
||||
let db = self.db.clone();
|
||||
let item_service = self.item_service.clone();
|
||||
let item_id = item_id;
|
||||
let filter = filter.clone();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let conn = db.blocking_lock();
|
||||
item_service.get_item_content_info_streaming(
|
||||
@@ -204,7 +206,7 @@ impl AsyncItemService {
|
||||
let mut buf = [0; PIPESIZE];
|
||||
while remaining > 0 {
|
||||
let to_read = std::cmp::min(remaining, buf.len() as u64);
|
||||
match reader.read(&mut buf[..to_read as usize]) {
|
||||
match reader.as_mut().unwrap().read(&mut buf[..to_read as usize]) {
|
||||
Ok(0) => break, // EOF reached before offset
|
||||
Ok(n) => remaining -= n as u64,
|
||||
Err(e) => {
|
||||
@@ -232,7 +234,7 @@ impl AsyncItemService {
|
||||
break; // We've read the requested length
|
||||
}
|
||||
|
||||
match reader.read(&mut buffer[..to_read]) {
|
||||
match reader.as_mut().unwrap().read(&mut buffer[..to_read]) {
|
||||
Ok(0) => break, // EOF
|
||||
Ok(n) => {
|
||||
let chunk = Bytes::copy_from_slice(&buffer[..n]);
|
||||
@@ -266,7 +268,7 @@ impl AsyncItemService {
|
||||
item_id: i64,
|
||||
filter: Option<String>,
|
||||
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.get_item_content_info_streaming(conn, item_id, filter)).await
|
||||
self.execute_blocking(move |conn, item_service| item_service.get_item_content_info_streaming(conn, item_id, filter)).await
|
||||
}
|
||||
|
||||
pub async fn find_item(
|
||||
@@ -275,7 +277,10 @@ impl AsyncItemService {
|
||||
tags: Vec<String>,
|
||||
meta: HashMap<String, String>,
|
||||
) -> Result<ItemWithMeta, CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.find_item(conn, &ids, &tags, &meta)).await
|
||||
let ids_clone = ids.clone();
|
||||
let tags_clone = tags.clone();
|
||||
let meta_clone = meta.clone();
|
||||
self.execute_blocking(move |conn, item_service| item_service.find_item(conn, &ids_clone, &tags_clone, &meta_clone)).await
|
||||
}
|
||||
|
||||
pub async fn list_items(
|
||||
@@ -283,7 +288,9 @@ impl AsyncItemService {
|
||||
tags: Vec<String>,
|
||||
meta: HashMap<String, String>,
|
||||
) -> Result<Vec<ItemWithMeta>, CoreError> {
|
||||
self.execute_blocking(|conn, item_service| item_service.list_items(conn, &tags, &meta)).await
|
||||
let tags_clone = tags.clone();
|
||||
let meta_clone = meta.clone();
|
||||
self.execute_blocking(move |conn, item_service| item_service.list_items(conn, &tags_clone, &meta_clone)).await
|
||||
}
|
||||
|
||||
pub async fn delete_item(&self, id: i64) -> Result<(), CoreError> {
|
||||
|
||||
Reference in New Issue
Block a user