diff --git a/src/modes/get.rs b/src/modes/get.rs index 39ecdba..157ed4f 100644 --- a/src/modes/get.rs +++ b/src/modes/get.rs @@ -59,15 +59,6 @@ pub fn mode_get( let (mut reader, _, _) = item_service.get_item_content_info_streaming( conn, item_id, - None, // head_bytes - None, // head_words - None, // head_lines - None, // tail_bytes - None, // tail_words - None, // tail_lines - None, // line_start - None, // line_end - None, // grep filter_str.clone(), )?; @@ -84,15 +75,6 @@ pub fn mode_get( let (new_reader, _, _) = item_service.get_item_content_info_streaming( conn, item_id, - None, - None, - None, - None, - None, - None, - None, - None, - None, filter_str.clone(), )?; reader = new_reader; diff --git a/src/services/async_item_service.rs b/src/services/async_item_service.rs index 696f1da..2aecc6c 100644 --- a/src/services/async_item_service.rs +++ b/src/services/async_item_service.rs @@ -206,14 +206,6 @@ impl AsyncItemService { // Get binary status using streaming approach let (_, _, is_binary) = self.get_item_content_info_streaming( item_id, - head_bytes, - head_words, - head_lines, - tail_bytes, - tail_words, - tail_lines, - line_start, - line_end, None ).await?; is_binary @@ -233,15 +225,6 @@ impl AsyncItemService { item_service.get_item_content_info_streaming( &conn, item_id, - head_bytes, - head_words, - head_lines, - tail_bytes, - tail_words, - tail_lines, - line_start, - line_end, - grep, None ).map(|(reader, _, _)| reader) }) @@ -342,15 +325,6 @@ impl AsyncItemService { item_service.get_item_content_info_streaming( &conn, item_id, - head_bytes, - head_words, - head_lines, - tail_bytes, - tail_words, - tail_lines, - line_start, - line_end, - grep, None ) }) diff --git a/src/services/item_service.rs b/src/services/item_service.rs index 7fb7ead..63a6e0f 100644 --- a/src/services/item_service.rs +++ b/src/services/item_service.rs @@ -151,9 +151,7 @@ impl ItemService { ) -> Result<(Vec, String, bool), CoreError> { // Use streaming approach to handle all filtering options consistently let (mut reader, mime_type, is_binary) = self.get_item_content_info_streaming( - conn, id, head_bytes, head_words, head_lines, - tail_bytes, tail_words, tail_lines, line_start, line_end, grep, - None + conn, id, None )?; // Read all the filtered content into a buffer @@ -163,46 +161,6 @@ impl ItemService { Ok((content, mime_type, is_binary)) } - /// Helper method to create a filter chain from parameters - fn create_filter_chain( - &self, - grep: Option, - head_bytes: Option, - head_lines: Option, - tail_bytes: Option, - tail_lines: Option, - filter: Option, - ) -> Result, CoreError> { - // Build filter string from individual parameters (for backward compatibility) - let mut filter_parts = Vec::new(); - if let Some(pattern) = grep { - filter_parts.push(format!("grep('{}')", pattern.replace('\'', "\\'"))); - } - 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)); - } - - // Handle the provided filter string - let filter_str = match (filter, filter_parts.is_empty()) { - (Some(f), true) => Some(f), - (Some(f), false) => Some(format!("{} | {}", f, filter_parts.join(" | "))), - (None, true) => None, - (None, false) => Some(filter_parts.join(" | ")), - }; - - // Create filter chain - self.filter_service.create_filter_chain(filter_str.as_deref()) - .map_err(|e| CoreError::InvalidInput(format!("Failed to create filter chain: {}", e))) - } /// Helper method to determine if content is binary fn is_content_binary( @@ -230,15 +188,6 @@ impl ItemService { &self, conn: &Connection, id: i64, - head_bytes: Option, - _head_words: Option, - head_lines: Option, - tail_bytes: Option, - _tail_words: Option, - tail_lines: Option, - _line_start: Option, - _line_end: Option, - grep: Option, filter: Option, ) -> Result<(Box, String, bool), CoreError> { let item_with_meta = self.get_item(conn, id)?; @@ -257,9 +206,8 @@ impl ItemService { )?; // Create filter chain - let filter_chain = self.create_filter_chain( - grep, head_bytes, head_lines, tail_bytes, tail_lines, filter - )?; + let filter_chain = self.filter_service.create_filter_chain(filter.as_deref()) + .map_err(|e| CoreError::InvalidInput(format!("Failed to create filter chain: {}", e)))?; // Wrap the reader with filtering let filtered_reader = Box::new(FilteringReader::new(reader, filter_chain));