tustvold commented on code in PR #2195:
URL: https://github.com/apache/arrow-rs/pull/2195#discussion_r931577147
##########
object_store/src/local.rs:
##########
@@ -804,11 +804,36 @@ fn convert_metadata(metadata: std::fs::Metadata,
location: Path) -> Result<Objec
}
/// Convert walkdir results and converts not-found errors into `None`.
+/// Convert broken symlinks to `None`.
fn convert_walkdir_result(
res: std::result::Result<walkdir::DirEntry, walkdir::Error>,
) -> Result<Option<walkdir::DirEntry>> {
match res {
- Ok(entry) => Ok(Some(entry)),
+ Ok(entry) => {
+ // To check for broken symlink: call symlink_metadata() - it does
not traverse symlinks);
+ // if ok: check if entry is symlink; and try to read it by calling
metadata().
+ match symlink_metadata(entry.path()) {
+ Ok(attr) => {
+ if attr.is_symlink() {
+ let target_metadata = metadata(entry.path());
+ match target_metadata {
+ Ok(_) => {
+ // symlink is valid
+ Ok(Some(entry))
+ }
+ Err(_) => {
Review Comment:
It might be nice to check the ErrorKind is NotFound
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]