Worktree: silence log message when dir is overwritten by file

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Max Brunsfeld 2021-04-20 10:12:48 -07:00
parent 5cbbf620ed
commit 85f8537017

View file

@ -782,7 +782,7 @@ impl BackgroundScanner {
let inode = metadata.ino(); let inode = metadata.ino();
let is_symlink = fs::symlink_metadata(&path) let is_symlink = fs::symlink_metadata(&path)
.context("symlink_metadata")? .context("failed to read symlink metadata")?
.file_type() .file_type()
.is_symlink(); .is_symlink();
let parent = if path == root_path { let parent = if path == root_path {
@ -790,7 +790,7 @@ impl BackgroundScanner {
} else { } else {
Some( Some(
fs::metadata(path.parent().unwrap()) fs::metadata(path.parent().unwrap())
.context("parent metadata")? .context("failed to read parent inode")?
.ino(), .ino(),
) )
}; };
@ -825,14 +825,11 @@ impl BackgroundScanner {
))) )))
} }
} }
Err(err) => { Err(err) => match (err.kind(), err.raw_os_error()) {
dbg!(&err); (io::ErrorKind::NotFound, _) => Ok(None),
if err.kind() == io::ErrorKind::NotFound { (io::ErrorKind::Other, Some(libc::ENOTDIR)) => Ok(None),
Ok(None) _ => Err(anyhow::Error::new(err)),
} else { },
Err(anyhow::Error::new(err)).context("fs::metadata")
}
}
} }
} }