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
.nested
.get("etc")
.unwrap()
.nested
.get("tmpfiles.d")
.unwrap()
.and_then(|etc| etc.nested.get("tmpfiles.d"))
.map_or(vec![], |tmpfiles_d| {
tmpfiles_d
.nested
.iter()
.map(|(_, node)| node.path.to_string_lossy().to_string())
.collect::<Vec<_>>();
.collect::<Vec<_>>()
});
let mut cmd = process::Command::new("systemd-tmpfiles");
cmd.arg("--create").arg("--remove").args(conf_files);
log::debug!("running {:#?}", cmd);