Fix the broken symlinks fetching

This commit is contained in:
Peltoche 2018-12-04 21:03:39 +01:00 committed by Pierre Peltier
parent 5b75642e66
commit aa7a54f703

View file

@ -31,15 +31,7 @@ pub struct Meta {
impl Meta {
pub fn from_path(path: &PathBuf) -> Option<Self> {
let mut metadata = match path.metadata() {
Ok(res) => res,
Err(err) => {
println!("cannot access '{}': {}", path.display(), err);
return None;
}
};
let file_type = FileType::from(&metadata);
let metadata;
if read_link(path).is_ok() {
// If the file is a link, retrieve the metadata without following
@ -48,9 +40,17 @@ impl Meta {
.symlink_metadata()
.expect("failed to retrieve symlink metadata");
} else {
metadata = path.metadata().expect("failed to retrieve metadata");
metadata = match path.metadata() {
Ok(res) => res,
Err(err) => {
println!("cannot access '{}': {}", path.display(), err);
return None;
}
};
}
let file_type = FileType::from(&metadata);
Some(Meta {
path: path.to_path_buf(),
symlink: SymLink::from_path(&path),