Skip to content

Commit

Permalink
♻️ Config::servicedir -> Config::servicedirs`
Browse files Browse the repository at this point in the history
This value is a `Vec<PathBuf>` so the plural seems more appropriate and consistent
  • Loading branch information
jokeyrhyme committed Nov 17, 2024
1 parent fc10870 commit e5a1264
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Config {
/// which tell the dbus-daemon how to start a program to provide a particular well-known bus
/// name.
#[serde(default)]
pub servicedir: Vec<PathBuf>,
pub servicedirs: Vec<PathBuf>,

/// Specifies the setuid helper that is used to launch system daemons with an alternate user.
pub servicehelper: Option<PathBuf>,
Expand Down Expand Up @@ -115,7 +115,7 @@ impl TryFrom<Document> for Config {
}
}
Element::Servicedir(p) => {
bc.servicedir.push(p);
bc.servicedirs.push(p);
}
Element::Servicehelper(p) => {
// NOTE: we're assuming this has the same "last one wins" behaviour as `<type>`
Expand All @@ -128,27 +128,27 @@ impl TryFrom<Document> for Config {
// TODO: warn and then ignore if we aren't reading: /etc/dbus-1/session.conf
if let Some(base) = BaseDirs::new() {
if let Some(runtime_dir) = base.runtime_dir() {
bc.servicedir
bc.servicedirs
.push(runtime_dir.join("dbus-1/services").to_path_buf());
}
bc.servicedir
bc.servicedirs
.push(base.data_dir().join("dbus-1/services").to_path_buf());
}
let mut servicedirs_in_data_dirs = xdg_data_dirs()
.iter()
.map(|p| p.join("dbus-1/services"))
.map(PathBuf::from)
.collect();
bc.servicedir.append(&mut servicedirs_in_data_dirs);
bc.servicedir
bc.servicedirs.append(&mut servicedirs_in_data_dirs);
bc.servicedirs
.push(PathBuf::from("/usr/share/dbus-1/services"));
// TODO: add Windows-specific session directories
}
Element::StandardSystemServicedirs => {
// NOTE: because servicedir sequence is important, we cannot de-duplicate this
// TODO: warn and then ignore if we aren't reading:
// /usr/share/dbus-1/system.conf
bc.servicedir
bc.servicedirs
.extend(STANDARD_SYSTEM_SERVICEDIRS.iter().map(PathBuf::from));
}
Element::Syslog => bc.syslog = true,
Expand Down Expand Up @@ -1114,11 +1114,11 @@ mod tests {

// TODO: improve test: contents are dynamic depending upon environment variables
assert_eq!(
busconfig.servicedir.first(),
busconfig.servicedirs.first(),
Some(&PathBuf::from("/example"))
);
assert_eq!(
busconfig.servicedir.last(),
busconfig.servicedirs.last(),
Some(&PathBuf::from("/usr/share/dbus-1/services"))
);
}
Expand All @@ -1140,7 +1140,7 @@ mod tests {
assert_eq!(
busconfig,
Config {
servicedir: vec![
servicedirs: vec![
PathBuf::from("/example"),
PathBuf::from("/usr/local/share/dbus-1/system-services"),
PathBuf::from("/usr/share/dbus-1/system-services"),
Expand Down

0 comments on commit e5a1264

Please sign in to comment.