refactor: Improve error handling and borrowing in item services
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -269,17 +269,17 @@ async fn handle_as_meta_response_with_metadata(
|
||||
pub async fn handle_post_item(
|
||||
State(_state): State<AppState>,
|
||||
) -> Result<Json<ApiResponse<ItemInfo>>, StatusCode> {
|
||||
|
||||
|
||||
// This is a simplified implementation
|
||||
// In a real implementation, you'd need to properly parse multipart/form-data
|
||||
// or JSON payload with the item data
|
||||
|
||||
|
||||
let response = ApiResponse::<ItemInfo> {
|
||||
success: false,
|
||||
data: None,
|
||||
error: Some("POST /api/item/ not yet implemented".to_string()),
|
||||
};
|
||||
|
||||
|
||||
Ok(Json(response))
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ impl AsyncItemService {
|
||||
f(&conn, &item_service)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.map_err(|e| CoreError::Other(anyhow::anyhow!("Blocking task failed: {}", e)))?
|
||||
}
|
||||
|
||||
pub async fn get_item(&self, id: i64) -> Result<ItemWithMeta, CoreError> {
|
||||
@@ -186,7 +186,7 @@ impl AsyncItemService {
|
||||
).map(|(reader, _, _)| reader)
|
||||
})
|
||||
.await
|
||||
.unwrap()?
|
||||
.map_err(|e| CoreError::Other(anyhow::anyhow!("Blocking task failed: {}", e)))?
|
||||
};
|
||||
|
||||
// Convert the reader into an async stream manually
|
||||
|
||||
@@ -59,7 +59,7 @@ impl<R: Read> Read for FilteringReader<R> {
|
||||
}
|
||||
|
||||
// Process through the filter chain if it exists
|
||||
if let Some(chain) = &mut self.filter_chain {
|
||||
if let Some(ref mut chain) = self.filter_chain {
|
||||
// Use a cursor to read the input data
|
||||
let mut input_cursor = std::io::Cursor::new(&temp_buf[..bytes_read]);
|
||||
// Write filtered output to our buffer
|
||||
|
||||
Reference in New Issue
Block a user