diff --git a/.gitignore b/.gitignore index b0987b2..4ede9dc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules/ .npm-cache/ .vfox/ .cargo-home/ +.rustup-home/ .vfox-home/ .env *.db diff --git a/crates/lightops-agent/src/actions.rs b/crates/lightops-agent/src/actions.rs index bec5fc6..1ce06e8 100644 --- a/crates/lightops-agent/src/actions.rs +++ b/crates/lightops-agent/src/actions.rs @@ -166,9 +166,11 @@ async fn system_snapshot() -> Result { ) .await .unwrap_or_default(); - let ports = command_lines(Command::new("ss").args(["-H", "-tulpen"]), 8) - .await - .or_else(|_| command_lines(Command::new("netstat").args(["-tulpen"]), 8).await) + let ports_result = match command_lines(Command::new("ss").args(["-H", "-tulpen"]), 8).await { + Ok(lines) => Ok(lines), + Err(_) => command_lines(Command::new("netstat").args(["-tulpen"]), 8).await, + }; + let ports = ports_result .unwrap_or_default() .into_iter() .take(80) @@ -762,9 +764,14 @@ async fn nginx_ssl_status() -> Result { .unwrap_or(false); let version = certbot .as_ref() - .map(stderr_text) - .filter(|text| !text.trim().is_empty()) - .or_else(|| certbot.as_ref().map(stdout_text)) + .map(|output| { + let stderr = stderr_text(output); + if stderr.trim().is_empty() { + stdout_text(output) + } else { + stderr + } + }) .unwrap_or_default(); let certbot_timer = run_command( Command::new("systemctl").args(["is-enabled", "certbot.timer"]), @@ -1776,7 +1783,7 @@ fn push_unique_json_string(obj: &mut serde_json::Map, key: &str, if value.is_empty() { return; } - let values = obj.entry(key.into()).or_insert_with(|| json!([])); + let values = obj.entry(key.to_string()).or_insert_with(|| json!([])); if let Some(array) = values.as_array_mut() { if !array.iter().any(|item| item.as_str() == Some(value)) { array.push(json!(value)); diff --git a/crates/lightops-agent/src/terminal.rs b/crates/lightops-agent/src/terminal.rs index 828d197..6cabfe3 100644 --- a/crates/lightops-agent/src/terminal.rs +++ b/crates/lightops-agent/src/terminal.rs @@ -41,8 +41,8 @@ pub fn open( pixel_height: 0, })?; let shell = std::env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string()); - let mut cmd = CommandBuilder::new(shell); - open_with_command(stream_id, tx, pair, &mut cmd) + let cmd = CommandBuilder::new(shell); + open_with_command(stream_id, tx, pair, cmd) } pub fn open_docker_exec( @@ -71,14 +71,14 @@ pub fn open_docker_exec( cmd.arg("-it"); cmd.arg(container_id); cmd.arg(shell); - open_with_command(stream_id, tx, pair, &mut cmd) + open_with_command(stream_id, tx, pair, cmd) } fn open_with_command( stream_id: String, tx: mpsc::UnboundedSender, pair: portable_pty::PtyPair, - cmd: &mut CommandBuilder, + mut cmd: CommandBuilder, ) -> Result { cmd.env("TERM", "xterm-256color"); let mut child = pair.slave.spawn_command(cmd)?; diff --git a/crates/lightops-server/src/handlers.rs b/crates/lightops-server/src/handlers.rs index 45bbcf1..6e92236 100644 --- a/crates/lightops-server/src/handlers.rs +++ b/crates/lightops-server/src/handlers.rs @@ -2750,7 +2750,7 @@ async fn open_or_update_alert_event( .bind(value) .bind(threshold) .bind(severity) - .bind(message) + .bind(&message) .bind(now) .bind(id) .execute(&state.pool) @@ -2768,7 +2768,7 @@ async fn open_or_update_alert_event( .bind(value) .bind(threshold) .bind(severity) - .bind(message) + .bind(&message) .bind(&now) .bind(&now) .execute(&state.pool) diff --git a/crates/lightops-server/src/store.rs b/crates/lightops-server/src/store.rs index afb2cc4..6efc27c 100644 --- a/crates/lightops-server/src/store.rs +++ b/crates/lightops-server/src/store.rs @@ -16,7 +16,7 @@ use lightops_common::api::ApiResponse; use serde::Deserialize; use serde_json::{json, Value}; use sqlx::Row; -use std::{fs, path::Path}; +use std::{fs, path::Path as FsPath}; use uuid::Uuid; const STORE_INSTALL_TIMEOUT_SECS: u64 = 600; @@ -161,7 +161,7 @@ async fn list_store_apps( .filter(|app| { q.category .as_ref() - .is_none_or(|category| app.category == category) + .is_none_or(|category| app.category == *category) }) .filter(|app| { q.q.as_ref().is_none_or(|keyword| { @@ -760,14 +760,14 @@ fn render_compose( } fn catalog() -> Vec { - let configured = load_catalog_from_dir(Path::new(STORE_CATALOG_DIR)); + let configured = load_catalog_from_dir(FsPath::new(STORE_CATALOG_DIR)); if !configured.is_empty() { return configured; } default_catalog() } -fn load_catalog_from_dir(dir: &Path) -> Vec { +fn load_catalog_from_dir(dir: &FsPath) -> Vec { let Ok(entries) = fs::read_dir(dir) else { return Vec::new(); }; @@ -797,7 +797,7 @@ fn load_catalog_from_dir(dir: &Path) -> Vec { } } } - apps.sort_by(|left, right| left.name.cmp(&right.name)); + apps.sort_by(|left: &StoreApp, right: &StoreApp| left.name.cmp(&right.name)); apps }