handle errors better

master
rascul 5 years ago
parent a0fb13f0fb
commit e22b56db45

@ -4,7 +4,7 @@ use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use crate::config::Config;
use crate::error::MkrootResult;
use crate::error::{MkrootError, MkrootResult};
pub fn os_release(config: &Config) -> MkrootResult<()> {
let mut path = PathBuf::from(&config.root_dir);
@ -23,9 +23,30 @@ pub fn os_release(config: &Config) -> MkrootResult<()> {
))?;
}
let mut perms = metadata(&path)?.permissions();
match metadata(&path) {
Ok(meta) => {
let mut perms = meta.permissions();
perms.set_mode(0o755);
if let Err(e) = set_permissions(&path, perms) {
return Err(MkrootError::from(format!(
"Error setting permissions {}: {}",
&path.display(),
e
)));
}
}
Err(e) => {
return Err(MkrootError::from(format!(
"Error reading metadata {}: {}",
&path.display(),
e
)))
}
}
/*let mut perms = metadata(&path)?.permissions();
perms.set_mode(0o644);
set_permissions(&path, perms)?;
set_permissions(&path, perms)?;*/
Ok(())
}

Loading…
Cancel
Save