From deec183ff56e95fe551cbd78d97e01825389e9c1 Mon Sep 17 00:00:00 2001 From: ZeroZipp Date: Fri, 22 May 2026 08:55:14 +0200 Subject: [PATCH] truncate output --- src/app/client.rs | 14 +++++++------- src/app/config.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/client.rs b/src/app/client.rs index 81981da..3ad2a88 100644 --- a/src/app/client.rs +++ b/src/app/client.rs @@ -88,7 +88,7 @@ async fn process_messages( return Err("Server did not respond to ping".into()); } next_message = stream.next() => { - if handle_stream_message(next_message, &outgoing_tx, config.max_output_bytes) + if handle_stream_message(next_message, &outgoing_tx, config.max_result_bytes) .await? { awaiting_pong = false; @@ -101,14 +101,14 @@ async fn process_messages( async fn handle_stream_message( message: Option>, outgoing_tx: &mpsc::Sender, - max_output_bytes: u64, + max_result_bytes: u64, ) -> Result { match message { Some(Ok(Message::Text(text))) => { handle_server_message( serde_json::from_str(&text).map_err(|error| error.to_string())?, outgoing_tx, - max_output_bytes, + max_result_bytes, ) .await?; Ok(false) @@ -130,11 +130,11 @@ async fn handle_stream_message( async fn handle_server_message( message: ServerMsg, outgoing_tx: &mpsc::Sender, - max_output_bytes: u64, + max_result_bytes: u64, ) -> Result<(), String> { match message { ServerMsg::Exec { exec_id, command } => { - spawn_command_task(exec_id, command, outgoing_tx.clone(), max_output_bytes); + spawn_command_task(exec_id, command, outgoing_tx.clone(), max_result_bytes); Ok(()) } ServerMsg::AuthError { reason } => Err(reason), @@ -146,11 +146,11 @@ fn spawn_command_task( exec_id: String, command: String, outgoing_tx: mpsc::Sender, - max_output_bytes: u64, + max_result_bytes: u64, ) { tokio::spawn(async move { info!("Executing [{exec_id}]: {command}"); - let (exit_code, stdout, stderr) = command::execute(&command, max_output_bytes).await; + let (exit_code, stdout, stderr) = command::execute(&command, max_result_bytes).await; let result = ClientMsg::ExecResult { exec_id, exit_code, diff --git a/src/app/config.rs b/src/app/config.rs index fadf6a3..e19ebfe 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -4,7 +4,7 @@ pub struct Config { pub token: String, pub device_id: String, pub base_url: String, - pub max_output_bytes: u64, + pub max_result_bytes: u64, pub writer_channel_capacity: usize, pub ping_interval: Duration, pub ping_timeout: Duration, @@ -13,7 +13,7 @@ pub struct Config { impl Config { const DEFAULT_BASE_URL: &str = "ws://127.0.0.1:8000"; const DEFAULT_DEVICE_ID: &str = "device"; - const DEFAULT_MAX_OUTPUT_BYTES: u64 = 10 * 1024 * 1024; + const DEFAULT_MAX_RESULT_BYTES: u64 = 10 * 1024 * 1024; const DEFAULT_WRITER_CHANNEL_CAPACITY: usize = 32; const DEFAULT_PING_INTERVAL_SECS: u64 = 30; const DEFAULT_PING_TIMEOUT_SECS: u64 = 10; @@ -31,7 +31,7 @@ impl Config { token, device_id, base_url, - max_output_bytes: parse_env("MAX_OUTPUT_BYTES", Self::DEFAULT_MAX_OUTPUT_BYTES), + max_result_bytes: parse_env("MAX_RESULT_BYTES", Self::DEFAULT_MAX_RESULT_BYTES), writer_channel_capacity: parse_env( "WRITER_CHANNEL_CAPACITY", Self::DEFAULT_WRITER_CHANNEL_CAPACITY,