systemd: avoid using unwrap

Co-authored-by: Ramses <ramses@well-founded.dev>
This commit is contained in:
Phani Rithvij 2024-11-08 18:30:19 +05:30 committed by GitHub
parent 79cd7d93e6
commit eb602df12b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,14 +10,14 @@ pub fn activate(etc_tree: &FileTree) -> TmpFilesActivationResult {
let conf_files = etc_tree let conf_files = etc_tree
.nested .nested
.get("etc") .get("etc")
.unwrap() .and_then(|etc| etc.nested.get("tmpfiles.d"))
.nested .map_or(vec![], |tmpfiles_d| {
.get("tmpfiles.d") tmpfiles_d
.unwrap()
.nested .nested
.iter() .iter()
.map(|(_, node)| node.path.to_string_lossy().to_string()) .map(|(_, node)| node.path.to_string_lossy().to_string())
.collect::<Vec<_>>(); .collect::<Vec<_>>()
});
let mut cmd = process::Command::new("systemd-tmpfiles"); let mut cmd = process::Command::new("systemd-tmpfiles");
cmd.arg("--create").arg("--remove").args(conf_files); cmd.arg("--create").arg("--remove").args(conf_files);
log::debug!("running {:#?}", cmd); log::debug!("running {:#?}", cmd);