diff --git a/cli/src/main.rs b/cli/src/main.rs index d48917a21..514beaa25 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -569,10 +569,10 @@ impl PathHash { /// Read a file. fn read(path: &Path) -> FileResult> { let f = |e| FileError::from_io(e, path); - if fs::metadata(&path).map_err(f)?.is_file() { - fs::read(&path).map_err(f) - } else { + if fs::metadata(&path).map_err(f)?.is_dir() { Err(FileError::IsDirectory) + } else { + fs::read(&path).map_err(f) } } diff --git a/tests/src/tests.rs b/tests/src/tests.rs index 66eb532f1..fef8c0cf5 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -324,10 +324,10 @@ fn read(path: &Path) -> FileResult> { .unwrap_or_else(|_| path.into()); let f = |e| FileError::from_io(e, &suffix); - if fs::metadata(&path).map_err(f)?.is_file() { - fs::read(&path).map_err(f) - } else { + if fs::metadata(&path).map_err(f)?.is_dir() { Err(FileError::IsDirectory) + } else { + fs::read(&path).map_err(f) } }