Skip to content

Commit a00d7d7

Browse files
committed
address review comments
1 parent 4df2f76 commit a00d7d7

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/uu/chmod/src/chmod.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -499,23 +499,17 @@ impl Chmoder {
499499
for entry_name in entries {
500500
let entry_path = dir_path.join(&entry_name);
501501

502-
// Get metadata for the entry
503-
let follow = self.traverse_symlinks == TraverseSymlinks::All;
504-
505-
let meta = match dir_fd.metadata_at(&entry_name, follow) {
506-
Ok(m) => m,
507-
Err(e) => {
508-
// Handle permission denied with proper file path context
509-
if e.kind() == std::io::ErrorKind::PermissionDenied {
510-
r = r.and(Err(ChmodError::PermissionDenied(
511-
entry_path.to_string_lossy().to_string(),
512-
)
513-
.into()));
514-
} else {
515-
r = r.and(Err(e.into()));
516-
}
517-
continue;
518-
}
502+
let dir_meta = dir_fd.metadata_at(&entry_name, should_follow_symlink);
503+
let Ok(meta) = dir_meta else {
504+
// Handle permission denied with proper file path context
505+
let e = dir_meta.unwrap_err();
506+
let error = if e.kind() == std::io::ErrorKind::PermissionDenied {
507+
ChmodError::PermissionDenied(entry_path.to_string_lossy().to_string()).into()
508+
} else {
509+
e.into()
510+
};
511+
r = r.and(Err(error));
512+
continue;
519513
};
520514

521515
if entry_path.is_symlink() {

0 commit comments

Comments
 (0)