From eee24f28326819ee839323c589f2249d267bb487 Mon Sep 17 00:00:00 2001 From: Reilly Wood Date: Mon, 23 Mar 2026 20:13:26 -0700 Subject: [PATCH 1/2] Fix -l/--limit flag not filtering unit files `get_unit_files()` was hardcoding `*.service` as the pattern for `list_unit_files_by_patterns`, ignoring the user's `-l` filter. When `merge_unit_files()` merged these results, all disabled/static/masked services got added back to the list. Closes #75 Co-Authored-By: Claude Opus 4.6 --- src/components/home.rs | 3 ++- src/systemd.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/home.rs b/src/components/home.rs index 7710e41..6b5c012 100644 --- a/src/components/home.rs +++ b/src/components/home.rs @@ -903,8 +903,9 @@ impl Component for Home { Action::RefreshUnitFiles => { let tx = self.action_tx.clone().unwrap(); let scope = self.scope; + let limit_units = self.limit_units.clone(); tokio::spawn(async move { - match systemd::get_unit_files(scope).await { + match systemd::get_unit_files(scope, &limit_units).await { Ok(unit_files) => { let _ = tx.send(Action::SetUnitFiles(unit_files)); }, diff --git a/src/systemd.rs b/src/systemd.rs index d3a4374..57c2888 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -132,7 +132,7 @@ impl UnitFile { /// Get unit files for all services, INCLUDING DISABLED ONES (ListUnits doesn't include those) /// This is slower than get_all_services. Takes about 100ms (user) and 300ms (global) on 13th gen Intel i7 -pub async fn get_unit_files(scope: Scope) -> Result> { +pub async fn get_unit_files(scope: Scope, services: &[String]) -> Result> { let start = std::time::Instant::now(); let mut unit_scopes = vec![]; @@ -163,7 +163,7 @@ pub async fn get_unit_files(scope: Scope) -> Result> { }, }; let manager_proxy = ManagerProxy::new(&connection).await?; - let unit_files = match manager_proxy.list_unit_files_by_patterns(vec![], vec!["*.service".into()]).await { + let unit_files = match manager_proxy.list_unit_files_by_patterns(vec![], services.iter().map(|s| s.to_string()).collect()).await { Ok(files) => { info!("get_unit_files: got {} {:?} unit files", files.len(), unit_scope); files From 37bc5ff2118ed3e15a0b0a1a524fdbefc294435c Mon Sep 17 00:00:00 2001 From: Reilly Wood Date: Mon, 23 Mar 2026 20:14:56 -0700 Subject: [PATCH 2/2] Fix formatting Co-Authored-By: Claude Opus 4.6 --- src/systemd.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/systemd.rs b/src/systemd.rs index 57c2888..1cbe0b0 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -163,21 +163,22 @@ pub async fn get_unit_files(scope: Scope, services: &[String]) -> Result { - info!("get_unit_files: got {} {:?} unit files", files.len(), unit_scope); - files - }, - Err(e) => { - error!("get_unit_files: list_unit_files_by_patterns failed for {:?}: {:?}", unit_scope, e); - if is_root && unit_scope == UnitScope::User { - info!("get_unit_files: ignoring user scope error because we're root"); - vec![] - } else { - return Err(e.into()); - } - }, - }; + let unit_files = + match manager_proxy.list_unit_files_by_patterns(vec![], services.iter().map(|s| s.to_string()).collect()).await { + Ok(files) => { + info!("get_unit_files: got {} {:?} unit files", files.len(), unit_scope); + files + }, + Err(e) => { + error!("get_unit_files: list_unit_files_by_patterns failed for {:?}: {:?}", unit_scope, e); + if is_root && unit_scope == UnitScope::User { + info!("get_unit_files: ignoring user scope error because we're root"); + vec![] + } else { + return Err(e.into()); + } + }, + }; let services = unit_files .into_iter()