From 91666fcaf6bea512a4b1feb71e8e2f51bc8b0cff Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 29 Sep 2022 12:10:25 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20follow=20directory=20symlinks?= =?UTF-8?q?=20found=20while=20walking=20(#280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 5417d8f45a..5cf565f649 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -76,7 +76,6 @@ pub fn iter_python_files<'a>( .all(|pattern| matches!(pattern, FilePattern::Simple(_))); WalkDir::new(normalize_path(path)) - .follow_links(true) .into_iter() .filter_entry(move |entry| { if !has_exclude && !has_extend_exclude { @@ -112,7 +111,9 @@ pub fn iter_python_files<'a>( }) .filter(|entry| { entry.as_ref().map_or(true, |entry| { - (entry.depth() == 0 && !entry.file_type().is_dir()) || is_included(entry.path()) + (entry.depth() == 0 || is_included(entry.path())) + && !entry.file_type().is_dir() + && !(entry.file_type().is_symlink() && entry.path().is_dir()) }) }) }