Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
},
Expand Down
33 changes: 17 additions & 16 deletions src/systemd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<UnitFile>> {
pub async fn get_unit_files(scope: Scope, services: &[String]) -> Result<Vec<UnitFile>> {
let start = std::time::Instant::now();

let mut unit_scopes = vec![];
Expand Down Expand Up @@ -163,21 +163,22 @@ pub async fn get_unit_files(scope: Scope) -> Result<Vec<UnitFile>> {
},
};
let manager_proxy = ManagerProxy::new(&connection).await?;
let unit_files = match manager_proxy.list_unit_files_by_patterns(vec![], vec!["*.service".into()]).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 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()
Expand Down
Loading