@@ -229,6 +229,17 @@ def __init__(self, data_name, data_in_name, data_filetype, data_file_size_min, d
229229
230230 logging .debug (f"{ size_data = } , { data_file_size_min = } , { data_file_size_max = } " )
231231
232+ # Loading excluded files
233+ with open (os .path .join (FF_Files .FF_LIB_FOLDER , "Settings" )) as excluded_file :
234+ data_excluded_files = load (excluded_file )["excluded_files" ]
235+
236+ # Checking if the search scope is an excluded directory
237+ excluded_files_block_search = False
238+ for excluded_file in data_excluded_files :
239+ if data_search_from_valid .startswith (excluded_file ):
240+ excluded_files_block_search = True
241+ break
242+
232243 # Fetching Errors
233244 # Testing if file ending, file groups or name contains are used together with name,
234245 # because if they do no file will be found
@@ -308,6 +319,20 @@ def __init__(self, data_name, data_in_name, data_filetype, data_file_size_min, d
308319 "No files would be found, because no file type "
309320 "category is selected." ,
310321 parent = None )
322+
323+ # If the search scope is an excluded file
324+ elif excluded_files_block_search :
325+ # Debug
326+ logging .error ("Directory Error! Search in directory is in an excluded directory" )
327+
328+ # Show Popup
329+ FF_Additional_UI .PopUps .show_critical_messagebox (
330+ "Directory Error!" ,
331+ "Directory Error!\n \n "
332+ "The directory you searched in is in an excluded folder.\n \n "
333+ "You can edit the excluded folders in the File Find Settings. \n (File Find > Preferences...)" ,
334+ parent = None )
335+
311336 # Start Searching
312337 else :
313338
@@ -348,15 +373,15 @@ class SignalClass(QObject):
348373 lambda : self .searching (
349374 data_name , data_in_name , data_filetype , data_file_size_min , data_file_size_max , data_library ,
350375 data_search_from_valid , data_search_for , data_content , unix_time_list , data_sort_by ,
351- data_reverse_sort , data_file_group , parent ))
376+ data_reverse_sort , data_file_group , data_excluded_files , parent ))
352377
353378 # Debug
354379 logging .debug ("Finished Setting up QThreadPool!" )
355380
356381 # The search engine
357382 def searching (self , data_name , data_in_name , data_filetype , data_file_size_min , data_file_size_max , data_library ,
358383 data_search_from , data_search_for , data_content , data_time , data_sort_by , data_reverse_sort ,
359- data_file_group , parent ):
384+ data_file_group , data_excluded_files , parent ):
360385 # Debug
361386 logging .info ("Starting Search..." )
362387 self .ui_logger .update ("Starting Search..." )
@@ -402,12 +427,15 @@ def searching(self, data_name, data_in_name, data_filetype, data_file_size_min,
402427 logging .debug ("Files and folders checking is NOT needed" )
403428 data_search_for_needed = True
404429
405- # Loading excluded files and checking if the need to be scanned
406- with open (os .path .join (FF_Files .FF_LIB_FOLDER , "Settings" )) as excluded_file :
407- data_excluded_files = load (excluded_file )["excluded_files" ]
430+ # Testing if one of the excluded folder is in the search scope, if not checking isn't necessary
431+ exclude_file_in_scope = False
432+ for excluded_test_file in data_excluded_files :
433+ if excluded_test_file .startswith (data_search_from ):
434+ exclude_file_in_scope = True
435+ break
408436
409- # If data_excluded_files is an empty list
410- if not data_excluded_files :
437+ # If data_excluded_files is an empty list or no file in the excluded list is in the search scope
438+ if not data_excluded_files or not exclude_file_in_scope :
411439 # If the list is empty
412440 logging .debug ("Excluded files checking is NOT needed" )
413441 data_excluded_files_needed = False
0 commit comments