fix: remove unused filter_plugin import and unused ringbuf import
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -417,61 +417,6 @@ impl MetaPlugin for TextMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Helper method to create a filter chain and process data
|
|
||||||
fn create_filter_and_process_data(&self, data: &[u8]) -> Vec<u8> {
|
|
||||||
// Check if we have head/tail options that would affect processing
|
|
||||||
let head_bytes = self.base.options.get("head_bytes")
|
|
||||||
.and_then(|v| v.as_u64())
|
|
||||||
.map(|v| v as usize);
|
|
||||||
let head_lines = self.base.options.get("head_lines")
|
|
||||||
.and_then(|v| v.as_u64())
|
|
||||||
.map(|v| v as usize);
|
|
||||||
let tail_bytes = self.base.options.get("tail_bytes")
|
|
||||||
.and_then(|v| v.as_u64())
|
|
||||||
.map(|v| v as usize);
|
|
||||||
let tail_lines = self.base.options.get("tail_lines")
|
|
||||||
.and_then(|v| v.as_u64())
|
|
||||||
.map(|v| v as usize);
|
|
||||||
|
|
||||||
// Build filter string from individual parameters
|
|
||||||
let mut filter_parts = Vec::new();
|
|
||||||
if let Some(bytes) = head_bytes {
|
|
||||||
filter_parts.push(format!("head_bytes({})", bytes));
|
|
||||||
}
|
|
||||||
if let Some(lines) = head_lines {
|
|
||||||
filter_parts.push(format!("head_lines({})", lines));
|
|
||||||
}
|
|
||||||
if let Some(bytes) = tail_bytes {
|
|
||||||
filter_parts.push(format!("tail_bytes({})", bytes));
|
|
||||||
}
|
|
||||||
if let Some(lines) = tail_lines {
|
|
||||||
filter_parts.push(format!("tail_lines({})", lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the filter service to process data
|
|
||||||
if !filter_parts.is_empty() {
|
|
||||||
let filter_str = filter_parts.join(" | ");
|
|
||||||
let filter_service = crate::services::filter_service::FilterService::new();
|
|
||||||
let mut filter_chain = match filter_service.create_filter_chain(Some(&filter_str)) {
|
|
||||||
Ok(chain) => chain,
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Failed to create filter chain: {}", e);
|
|
||||||
return data.to_vec();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Process the data through the filter chain
|
|
||||||
match filter_service.process_data(&mut filter_chain, data) {
|
|
||||||
Ok(processed) => processed,
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Failed to process data through filter: {}", e);
|
|
||||||
data.to_vec()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data.to_vec()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update(&mut self, data: &[u8]) -> MetaPluginResponse {
|
fn update(&mut self, data: &[u8]) -> MetaPluginResponse {
|
||||||
// If already finalized, don't process more data
|
// If already finalized, don't process more data
|
||||||
@@ -483,7 +428,7 @@ impl MetaPlugin for TextMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut metadata = Vec::new();
|
let mut metadata = Vec::new();
|
||||||
let processed_data = self.create_filter_and_process_data(data);
|
let processed_data = data.to_vec();
|
||||||
|
|
||||||
// If we haven't determined if content is binary yet, build buffer and check
|
// If we haven't determined if content is binary yet, build buffer and check
|
||||||
if self.is_binary_content.is_none() {
|
if self.is_binary_content.is_none() {
|
||||||
|
|||||||
@@ -307,11 +307,11 @@ pub async fn handle_get_item_latest_content(
|
|||||||
let item_id = item.item.id.unwrap();
|
let item_id = item.item.id.unwrap();
|
||||||
let metadata = item.meta_as_map();
|
let metadata = item.meta_as_map();
|
||||||
// Handle as_meta parameter
|
// Handle as_meta parameter
|
||||||
if params.as_meta {
|
if params.as_meta.unwrap_or(false) {
|
||||||
// Force stream=false and allow_binary=false for as_meta=true
|
// Force stream=false and allow_binary=false for as_meta=true
|
||||||
handle_as_meta_response_with_metadata(&item_service, item_id, &metadata, params.offset, params.length).await
|
handle_as_meta_response_with_metadata(&item_service, item_id, &metadata, params.offset.unwrap_or(0), params.length.unwrap_or(0)).await
|
||||||
} else {
|
} else {
|
||||||
stream_item_content_response_with_metadata(&item_service, item_id, &metadata, params.allow_binary, params.offset, params.length, params.stream).await
|
stream_item_content_response_with_metadata(&item_service, item_id, &metadata, params.allow_binary.unwrap_or(false), params.offset.unwrap_or(0), params.length.unwrap_or(0), params.stream.unwrap_or(false)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(CoreError::ItemNotFoundGeneric) => Err(StatusCode::NOT_FOUND),
|
Err(CoreError::ItemNotFoundGeneric) => Err(StatusCode::NOT_FOUND),
|
||||||
@@ -371,15 +371,15 @@ pub async fn handle_get_item_content(
|
|||||||
state.settings.clone()
|
state.settings.clone()
|
||||||
);
|
);
|
||||||
// Handle as_meta parameter
|
// Handle as_meta parameter
|
||||||
if params.as_meta {
|
if params.as_meta.unwrap_or(false) {
|
||||||
// Force stream=false and allow_binary=false for as_meta=true
|
// Force stream=false and allow_binary=false for as_meta=true
|
||||||
let result = handle_as_meta_response(&item_service, item_id, params.offset, params.length).await;
|
let result = handle_as_meta_response(&item_service, item_id, params.offset.unwrap_or(0), params.length.unwrap_or(0)).await;
|
||||||
if let Ok(response) = &result {
|
if let Ok(response) = &result {
|
||||||
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
|
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
let result = stream_item_content_response(&item_service, item_id, params.allow_binary, params.offset, params.length, params.stream).await;
|
let result = stream_item_content_response(&item_service, item_id, params.allow_binary.unwrap_or(false), params.offset.unwrap_or(0), params.length.unwrap_or(0), params.stream.unwrap_or(false)).await;
|
||||||
if let Ok(response) = &result {
|
if let Ok(response) = &result {
|
||||||
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
|
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,9 +361,15 @@ impl AsyncItemService {
|
|||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
meta: HashMap<String, String>,
|
meta: HashMap<String, String>,
|
||||||
) -> Result<ItemWithMeta, CoreError> {
|
) -> Result<ItemWithMeta, CoreError> {
|
||||||
self.execute_blocking(|conn, item_service| {
|
let db = self.db.clone();
|
||||||
item_service.find_item(conn, &ids, &tags, &meta)
|
let item_service = self.item_service.clone();
|
||||||
}).await
|
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let conn = db.blocking_lock();
|
||||||
|
item_service.find_item(&conn, &ids, &tags, &meta)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_items(
|
pub async fn list_items(
|
||||||
@@ -371,15 +377,27 @@ impl AsyncItemService {
|
|||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
meta: HashMap<String, String>,
|
meta: HashMap<String, String>,
|
||||||
) -> Result<Vec<ItemWithMeta>, CoreError> {
|
) -> Result<Vec<ItemWithMeta>, CoreError> {
|
||||||
self.execute_blocking(|conn, item_service| {
|
let db = self.db.clone();
|
||||||
item_service.list_items(conn, &tags, &meta)
|
let item_service = self.item_service.clone();
|
||||||
}).await
|
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let conn = db.blocking_lock();
|
||||||
|
item_service.list_items(&conn, &tags, &meta)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_item(&self, id: i64) -> Result<(), CoreError> {
|
pub async fn delete_item(&self, id: i64) -> Result<(), CoreError> {
|
||||||
self.execute_blocking_mut(|conn, item_service| {
|
let db = self.db.clone();
|
||||||
item_service.delete_item(conn, id)
|
let item_service = self.item_service.clone();
|
||||||
}).await
|
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let mut conn = db.blocking_lock();
|
||||||
|
item_service.delete_item(&mut conn, id)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn save_item_from_mcp(
|
pub async fn save_item_from_mcp(
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ use crate::services::types::{ItemWithContent, ItemWithMeta};
|
|||||||
use crate::db::{self, Meta};
|
use crate::db::{self, Meta};
|
||||||
use crate::compression_engine::{get_compression_engine, CompressionType};
|
use crate::compression_engine::{get_compression_engine, CompressionType};
|
||||||
use crate::modes::common::settings_compression_type;
|
use crate::modes::common::settings_compression_type;
|
||||||
use crate::filter_plugin::FilterChain;
|
|
||||||
use clap::Command;
|
use clap::Command;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use ringbuf::HeapRb;
|
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@@ -213,7 +211,6 @@ impl ItemService {
|
|||||||
line_start: Option<usize>,
|
line_start: Option<usize>,
|
||||||
line_end: Option<usize>,
|
line_end: Option<usize>,
|
||||||
grep: Option<String>,
|
grep: Option<String>,
|
||||||
filter: Option<String>,
|
|
||||||
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
|
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
|
||||||
let item_with_meta = self.get_item(conn, id)?;
|
let item_with_meta = self.get_item(conn, id)?;
|
||||||
let item_id = item_with_meta.item.id.ok_or_else(|| CoreError::InvalidInput("Item missing ID".to_string()))?;
|
let item_id = item_with_meta.item.id.ok_or_else(|| CoreError::InvalidInput("Item missing ID".to_string()))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user