mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #9990 from cerdelen/chmod_recursive_hyper_nested_dirs
Chmod recursive hyper nested dirs
This commit is contained in:
@@ -432,14 +432,20 @@ impl Chmoder {
|
||||
|
||||
// If the path is a directory (or we should follow symlinks), recurse into it
|
||||
if (!file_path.is_symlink() || should_follow_symlink) && file_path.is_dir() {
|
||||
// We buffer all paths in this dir to not keep to be able to close the fd so not
|
||||
// too many fd's are open during the recursion
|
||||
let mut paths_in_this_dir = Vec::new();
|
||||
|
||||
for dir_entry in file_path.read_dir()? {
|
||||
let path = match dir_entry {
|
||||
Ok(entry) => entry.path(),
|
||||
match dir_entry {
|
||||
Ok(entry) => paths_in_this_dir.push(entry.path()),
|
||||
Err(err) => {
|
||||
r = r.and(Err(err.into()));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
for path in paths_in_this_dir {
|
||||
if path.is_symlink() {
|
||||
r = self.handle_symlink_during_recursion(&path).and(r);
|
||||
} else {
|
||||
|
||||
@@ -407,6 +407,16 @@ fn test_chmod_recursive_correct_exit_code() {
|
||||
.stderr_is(err_msg);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chmod_hyper_recursive_directory_tree_does_not_fail() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mkdir = "a/".repeat(400);
|
||||
|
||||
at.mkdir_all(&mkdir);
|
||||
|
||||
ucmd.arg("-R").arg("777").arg("a").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
fn test_chmod_recursive() {
|
||||
|
||||
Reference in New Issue
Block a user