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.
|
/// Read a file.
|
||||||
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
||||||
let f = |e| FileError::from_io(e, path);
|
let f = |e| FileError::from_io(e, path);
|
||||||
if fs::metadata(&path).map_err(f)?.is_file() {
|
if fs::metadata(&path).map_err(f)?.is_dir() {
|
||||||
fs::read(&path).map_err(f)
|
|
||||||
} else {
|
|
||||||
Err(FileError::IsDirectory)
|
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());
|
.unwrap_or_else(|_| path.into());
|
||||||
|
|
||||||
let f = |e| FileError::from_io(e, &suffix);
|
let f = |e| FileError::from_io(e, &suffix);
|
||||||
if fs::metadata(&path).map_err(f)?.is_file() {
|
if fs::metadata(&path).map_err(f)?.is_dir() {
|
||||||
fs::read(&path).map_err(f)
|
|
||||||
} else {
|
|
||||||
Err(FileError::IsDirectory)
|
Err(FileError::IsDirectory)
|
||||||
|
} else {
|
||||||
|
fs::read(&path).map_err(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user