Skip to content

Commit b7ccbf6

Browse files
committed
use NotADirectory io error kind where appropriate
1 parent c2d1a5d commit b7ccbf6

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

gix-fs/tests/dir/remove.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ mod empty_upwards_until_boundary {
3434
let dir = tempfile::tempdir()?;
3535
let target = dir.path().join("actually-a-file");
3636
std::fs::write(&target, [42])?;
37-
assert!(remove::empty_upward_until_boundary(&target, dir.path()).is_err()); // TODO: check for IsNotADirectory when it becomes stable
37+
38+
let res = remove::empty_upward_until_boundary(&target, dir.path());
39+
assert!(res.is_err());
40+
assert!(res.err().unwrap().kind() == io::ErrorKind::NotADirectory);
3841
assert!(target.is_file(), "it didn't touch the file");
3942
assert!(dir.path().is_dir(), "it won't touch the boundary");
4043
Ok(())

gix-glob/src/search/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn io_err_is_dir(err: &std::io::Error) -> bool {
6868
let raw = err.raw_os_error();
6969
raw == Some(if cfg!(windows) { 5 } else { 21 }) /* Not a directory */
7070
/* Also that, but under different circumstances */
71-
|| raw == Some(20)
71+
|| raw == Some(20) || err.kind() == std::io::ErrorKind::NotADirectory
7272
}
7373

7474
/// Instantiation

gix-odb/src/store_impls/dynamic/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Store {
8989
)?;
9090
if !objects_dir.is_dir() {
9191
return Err(std::io::Error::new(
92-
std::io::ErrorKind::Other, // TODO: use NotADirectory when stabilized
92+
std::io::ErrorKind::NotADirectory,
9393
format!("'{}' wasn't a directory", objects_dir.display()),
9494
));
9595
}

0 commit comments

Comments
 (0)