Merge pull request #814 from thegedge/fix-ls-bug-with-broken-symlinks

Ignore errors in `ls`.
This commit is contained in:
Jonathan Turner 2019-10-14 05:52:02 +13:00 committed by GitHub
commit bd6ca75032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,13 +128,16 @@ impl Shell for FilesystemShell {
} }
if let Ok(entry) = entry { if let Ok(entry) = entry {
let filepath = entry.path(); let filepath = entry.path();
let filename = if let Ok(fname) = filepath.strip_prefix(&cwd) { if let Ok(metadata) = std::fs::symlink_metadata(&filepath) {
fname let filename = if let Ok(fname) = filepath.strip_prefix(&cwd) {
} else { fname
Path::new(&filepath) } else {
}; Path::new(&filepath)
let value = dir_entry_dict(filename, &entry.metadata().unwrap(), &name_tag)?; };
yield ReturnSuccess::value(value);
let value = dir_entry_dict(filename, &metadata, &name_tag)?;
yield ReturnSuccess::value(value);
}
} }
} }
}; };
@ -164,14 +167,16 @@ impl Shell for FilesystemShell {
break; break;
} }
if let Ok(entry) = entry { if let Ok(entry) = entry {
let filename = if let Ok(fname) = entry.strip_prefix(&cwd) { if let Ok(metadata) = std::fs::symlink_metadata(&entry) {
fname let filename = if let Ok(fname) = entry.strip_prefix(&cwd) {
} else { fname
Path::new(&entry) } else {
}; Path::new(&entry)
let metadata = std::fs::metadata(&entry).unwrap(); };
if let Ok(value) = dir_entry_dict(filename, &metadata, &name_tag) {
yield ReturnSuccess::value(value); if let Ok(value) = dir_entry_dict(filename, &metadata, &name_tag) {
yield ReturnSuccess::value(value);
}
} }
} }
} }