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,15 +128,18 @@ impl Shell for FilesystemShell {
}
if let Ok(entry) = entry {
let filepath = entry.path();
if let Ok(metadata) = std::fs::symlink_metadata(&filepath) {
let filename = if let Ok(fname) = filepath.strip_prefix(&cwd) {
fname
} else {
Path::new(&filepath)
};
let value = dir_entry_dict(filename, &entry.metadata().unwrap(), &name_tag)?;
let value = dir_entry_dict(filename, &metadata, &name_tag)?;
yield ReturnSuccess::value(value);
}
}
}
};
return Ok(stream.to_output_stream());
}
@ -164,17 +167,19 @@ impl Shell for FilesystemShell {
break;
}
if let Ok(entry) = entry {
if let Ok(metadata) = std::fs::symlink_metadata(&entry) {
let filename = if let Ok(fname) = entry.strip_prefix(&cwd) {
fname
} 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);
}
}
}
}
};
Ok(stream.to_output_stream())
}