Skip to content

Commit 3e3cf87

Browse files
committed
symlink depth calculation(#1)
1 parent f87d777 commit 3e3cf87

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ fn retrieve_symlink<'a>(
373373
meta: Option<std::fs::Metadata>,
374374
depth: i32,
375375
) -> Result<(FindContext<'a>, u64)> {
376-
if depth >= ctx.max_depth {
377-
return Ok((ctx.with_path(parent), 0));
378-
}
376+
// if depth >= ctx.max_depth {
377+
// return Ok((ctx.with_path(parent), 0));
378+
// }
379379
let path = ctx.path.clone();
380380
let link_target = match std::fs::read_link(path.clone()) {
381381
Ok(v) => v,
@@ -399,6 +399,7 @@ fn retrieve_symlink<'a>(
399399
let ftype = v.file_type();
400400
if ftype.is_symlink() {
401401
ctx = ctx.with_path(link_path.as_path());
402+
// increase depth for preventing infinite loop if symlink points itself
402403
return retrieve_symlink(ctx, parent, Some(v), depth + 1);
403404
}
404405
if ftype.is_file() {

0 commit comments

Comments
 (0)