feat: replace hardcoded buffer sizes with PIPESIZE constant
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -2,6 +2,7 @@ use anyhow::{anyhow, Result};
|
||||
use std::io::{Write};
|
||||
|
||||
use crate::common::is_binary::is_binary;
|
||||
use crate::common::PIPESIZE;
|
||||
use crate::config;
|
||||
use crate::services::item_service::ItemService;
|
||||
use clap::Command;
|
||||
@@ -61,7 +62,7 @@ pub fn mode_get(
|
||||
|
||||
if detect_binary {
|
||||
// Read only the first 8192 bytes for binary detection
|
||||
let mut sample_buffer = vec![0; 8192];
|
||||
let mut sample_buffer = vec![0; PIPESIZE];
|
||||
let bytes_read = reader.read(&mut sample_buffer)?;
|
||||
if is_binary(&sample_buffer[..bytes_read]) {
|
||||
return Err(anyhow!(
|
||||
@@ -77,7 +78,7 @@ pub fn mode_get(
|
||||
|
||||
// Stream the content to stdout
|
||||
let mut stdout = std::io::stdout();
|
||||
let mut buffer = [0; 8192];
|
||||
let mut buffer = [0; PIPESIZE];
|
||||
loop {
|
||||
let bytes_read = reader.read(&mut buffer)?;
|
||||
if bytes_read == 0 {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::common::PIPESIZE;
|
||||
use crate::services::error::CoreError;
|
||||
use crate::services::item_service::ItemService;
|
||||
use crate::services::types::{ItemWithContent, ItemWithMeta};
|
||||
@@ -204,7 +205,7 @@ impl AsyncItemService {
|
||||
// Apply offset by reading and discarding bytes
|
||||
if offset > 0 {
|
||||
let mut remaining = offset;
|
||||
let mut buf = [0; 8192];
|
||||
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]) {
|
||||
@@ -220,7 +221,7 @@ impl AsyncItemService {
|
||||
|
||||
// Read and send data up to the specified length
|
||||
let mut remaining_length = length;
|
||||
let mut buffer = [0; 8192];
|
||||
let mut buffer = [0; PIPESIZE];
|
||||
|
||||
loop {
|
||||
// Determine how much to read in this iteration
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::common::PIPESIZE;
|
||||
use crate::config::Settings;
|
||||
use crate::services::compression_service::CompressionService;
|
||||
use crate::services::error::CoreError;
|
||||
@@ -274,7 +275,7 @@ impl ItemService {
|
||||
|
||||
let mut item_out = compression_engine.create(item_path.clone())?;
|
||||
|
||||
let mut buffer = [0; 8192];
|
||||
let mut buffer = [0; PIPESIZE];
|
||||
let mut total_bytes = 0;
|
||||
|
||||
debug!("ITEM_SERVICE: Starting to read and process input data");
|
||||
|
||||
Reference in New Issue
Block a user