From 4d9c6b28d0a811ed7bd090a95774baf3bfa94c55 Mon Sep 17 00:00:00 2001 From: Johannes Wolf <519002+johannes-wolf@users.noreply.github.com> Date: Thu, 30 Mar 2023 00:36:22 +0200 Subject: [PATCH] cli: Allow reading every path not of type dir (#414) --- cli/src/main.rs | 6 +++--- tests/src/tests.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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) } }