Skip to content

Commit

Permalink
feat: recursively walk symlinks pointing at dirs
Browse files Browse the repository at this point in the history
Before:

```
/tmp/test-recursive-dir-symlinks
├── dir
│  └── test.txt
└── symlinkdir -> /tmp/test-recursive-dir-symlinks/dir
```

After:

```
/tmp/test-recursive-dir-symlinks
├── dir
│  └── test.txt
└── symlinkdir -> /tmp/test-recursive-dir-symlinks/dir
   └── test.txt
```

Signed-off-by: Ihar Hrachyshka <[email protected]>
  • Loading branch information
booxter authored and cafkafk committed Sep 1, 2024
1 parent 4151568 commit 9a0a0a4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl<'args> Exa<'args> {
let mut child_dirs = Vec::new();
for child_dir in children
.iter()
.filter(|f| f.is_directory() && !f.is_all_all)
.filter(|f| f.points_to_directory() && !f.is_all_all)
{
match child_dir.to_dir() {
Ok(d) => child_dirs.push(d),
Expand Down
2 changes: 1 addition & 1 deletion src/output/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl<'a> Render<'a> {

let mut dir = None;
if let Some(r) = self.recurse {
if file.is_directory() && r.tree && !r.is_too_deep(depth.0) {
if file.points_to_directory() && r.tree && !r.is_too_deep(depth.0) {
trace!("matching on to_dir");
match file.to_dir() {
Ok(d) => {
Expand Down
5 changes: 5 additions & 0 deletions tests/cmd/absolute_recurse_unix.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
[CWD]/tests/itest/q
[CWD]/tests/itest/vagrant

tests/itest/dir-symlink:
[CWD]/tests/itest/dir-symlink/a
[CWD]/tests/itest/dir-symlink/symlink -> a
[CWD]/tests/itest/dir-symlink/symlink-broken -> ./b

tests/itest/exa:
[CWD]/tests/itest/exa/file.c -> djihisudjuhfius
[CWD]/tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
Expand Down
2 changes: 2 additions & 0 deletions tests/gen/long_links_recurse_unix.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,8 @@ tests/test_dir/symlinks:

tests/test_dir/symlinks/dir:

tests/test_dir/symlinks/symlink3:

tests/test_dir/time:
1 1d
1 1h
Expand Down
2 changes: 2 additions & 0 deletions tests/gen/recursive_long_unix.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,8 @@ symlink4 -> pipitek

tests/test_dir/symlinks/dir:

tests/test_dir/symlinks/symlink3:

tests/test_dir/time:
1d
1h
Expand Down
2 changes: 2 additions & 0 deletions tests/gen/recursive_unix.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,8 @@ symlink4 -> pipitek

tests/test_dir/symlinks/dir:

tests/test_dir/symlinks/symlink3:

tests/test_dir/time:
1d
1h
Expand Down

0 comments on commit 9a0a0a4

Please sign in to comment.