From 36c4493cd6c48e3b03a929a1adb65d205153df3c Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Sun, 16 Jul 2017 14:05:48 -0400 Subject: [PATCH] Fix handling of symlinks --- bin/filecheck.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/filecheck.py b/bin/filecheck.py index 7bc9179..0450550 100644 --- a/bin/filecheck.py +++ b/bin/filecheck.py @@ -732,12 +732,13 @@ class KittenGroomerFileCheck(KittenGroomerBase): queue = [] for path in sorted(os.listdir(root_dir_path), key=lambda x: str.lower(x)): full_path = os.path.join(root_dir_path, path) - if os.path.isdir(full_path): + # check for symlinks first to prevent getting trapped in infinite symlink recursion + if os.path.islink(full_path): + queue.append(full_path) + elif os.path.isdir(full_path): queue.append(full_path) queue += self.list_files_dirs(full_path) - elif os.path.isfile(full_path, follow_symlinks=False): - queue.append(full_path) - elif os.path.islink(full_path): + elif os.path.isfile(full_path): queue.append(full_path) return queue