mirror of
https://github.com/lsd-rs/lsd
synced 2025-03-05 07:27:20 +00:00
Fix the broken symlinks fetching
This commit is contained in:
parent
5b75642e66
commit
aa7a54f703
1 changed files with 10 additions and 10 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue