From 6e1d86f311f4a93f13a93fba1f042f69fee1916b Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 10 Nov 2025 18:18:40 +0100 Subject: [PATCH] fs: Handle io::ErrorKind::NotADirectory in fs::metadata (#42370) New error variants were stabilized in 1.83, and this might've led to us mis-handling not-a-directory errors. Co-authored-by: Dino Release Notes: - N/A Co-authored-by: Dino --- crates/fs/src/fs.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 53af6ba6afc50cb0e568a01e25d1af22c02d9e36..b8714505093f03828e3d8783204ede61bb0989b0 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -719,9 +719,8 @@ impl Fs for RealFs { { Ok(metadata) => metadata, Err(err) => { - return match (err.kind(), err.raw_os_error()) { - (io::ErrorKind::NotFound, _) => Ok(None), - (io::ErrorKind::Other, Some(libc::ENOTDIR)) => Ok(None), + return match err.kind() { + io::ErrorKind::NotFound | io::ErrorKind::NotADirectory => Ok(None), _ => Err(anyhow::Error::new(err)), }; }