Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/uu/sum/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ fn open(name: &OsString) -> UResult<Reader> {

// Silent the warning as we want to the error message
match path.metadata() {
Ok(_) => {
if path.is_dir() {
return Err(USimpleError::new(
1,
translate!("sum-error-is-directory", "name" => name.maybe_quote()),
));
}
// some platforms cannot catch this as read error. Needs additional cost by stat
#[cfg(any(target_os = "wasi", target_os = "windows"))]
Ok(_) if path.is_dir() => {
return Err(USimpleError::new(
1,
translate!("sum-error-is-directory", "name" => name.maybe_quote()),
));
}
Ok(_) => {}
Err(err) => {
if err.kind() == ErrorKind::NotFound {
return Err(USimpleError::new(
Expand Down
Loading