From a1f249d1bea670aad5dc9997cd04a72b687b73cb Mon Sep 17 00:00:00 2001 From: Filip Brygidyn Date: Sat, 14 Dec 2019 19:00:40 +0100 Subject: [PATCH 4/4] Walk Method: Avoid yielding link related duplicate results diff --git a/catfish/CatfishSearchEngine.py b/catfish/CatfishSearchEngine.py index 178c1f50..783919b5 100644 --- a/catfish/CatfishSearchEngine.py +++ b/catfish/CatfishSearchEngine.py @@ -354,6 +354,10 @@ class CatfishSearchMethod_Walk(CatfishSearchMethod): # Enable symbolic link directories, but process once processed_links = [] + # Keep a copy of what we found to make sure there are no duplicates + # caused by soft links + yielded_paths = [] + # Grab the special directory list to get them precedence xdgdirlist = [ GLib.get_user_special_dir(GLib.USER_DIRECTORY_DESKTOP), @@ -391,7 +395,11 @@ class CatfishSearchMethod_Walk(CatfishSearchMethod): # Check paths in the second and deeper levels of the selected directory for path in paths: if any(keyword in path.lower() for keyword in keywords): - yield os.path.join(root, path) + yield_path = os.path.join(root, path) + if os.path.realpath(yield_path) in yielded_paths: + continue + yielded_paths.append(os.path.realpath(yield_path)) + yield yield_path yield True yield False -- 2.24.0