Skip to content

Commit 1f78fc6

Browse files
committed
refactor: remove handle_permission_denied function from rm linux platform
Remove the obsolete `handle_permission_denied` helper function in `src/uu/rm/src/platform/linux.rs`. This function was handling permission denied errors when attempting to remove subdirectories during recursive removal. Its removal simplifies the code and aligns with updated error handling logic, potentially avoiding redundant or buggy behavior in edge cases. The change maintains compatibility for standard rm operations while reducing complexity.
1 parent 2957789 commit 1f78fc6

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

src/uu/rm/src/platform/linux.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -187,37 +187,6 @@ fn handle_error_with_force(e: std::io::Error, path: &Path, options: &Options) ->
187187
!options.force
188188
}
189189

190-
/// Helper to handle permission denied errors
191-
fn handle_permission_denied(
192-
dir_fd: &DirFd,
193-
entry_name: &OsStr,
194-
entry_path: &Path,
195-
options: &Options,
196-
) -> bool {
197-
// When we can't open a subdirectory due to permission denied,
198-
// try to remove it directly (it might be empty).
199-
// This matches GNU rm behavior with -f flag.
200-
if let Err(remove_err) = dir_fd.unlink_at(entry_name, true) {
201-
// Failed to remove - show appropriate error
202-
if remove_err.kind() == std::io::ErrorKind::PermissionDenied {
203-
// Permission denied errors are always shown, even with force
204-
show_permission_denied_error(entry_path);
205-
return true;
206-
} else if !options.force {
207-
let remove_err = remove_err.map_err_context(
208-
|| translate!("rm-error-cannot-remove", "file" => entry_path.quote()),
209-
);
210-
show_error!("{remove_err}");
211-
return true;
212-
}
213-
// With force mode, suppress non-permission errors
214-
return !options.force;
215-
}
216-
// Successfully removed empty directory
217-
verbose_removed_directory(entry_path, options);
218-
false
219-
}
220-
221190
/// Helper to handle unlink operation with error reporting
222191
fn handle_unlink(
223192
dir_fd: &DirFd,

0 commit comments

Comments
 (0)