cli: Allow reading every path not of type dir (#414)
This commit is contained in:
parent
dffaef0832
commit
4d9c6b28d0
@ -569,10 +569,10 @@ impl PathHash {
|
||||
/// Read a file.
|
||||
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,10 +324,10 @@ fn read(path: &Path) -> FileResult<Vec<u8>> {
|
||||
.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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user