mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Fix partial regex match yielding false positive
This commit is contained in:
parent
0b46ca2222
commit
ab8750eedb
@ -108,18 +108,24 @@ class Directories:
|
||||
found_files = []
|
||||
# print(f"len of files: {len(files)} {files}")
|
||||
for f in files:
|
||||
found = False
|
||||
matched = False
|
||||
for expr in self._exclude_list.compiled_files:
|
||||
if expr.match(f):
|
||||
found = True
|
||||
if expr.fullmatch(f):
|
||||
logging.debug(f"{expr} matched {f}.")
|
||||
matched = True
|
||||
break
|
||||
if not found:
|
||||
if not matched:
|
||||
logging.debug(f"path {root + os.sep + f}")
|
||||
for expr in self._exclude_list.compiled_paths:
|
||||
if expr.match(root + os.sep + f):
|
||||
found = True
|
||||
if expr.fullmatch(root + os.sep + f):
|
||||
print(f"{expr} matched {root}{os.sep}{f}.")
|
||||
matched = True
|
||||
break
|
||||
if not found:
|
||||
if not matched:
|
||||
logging.debug(f"Not filtering: {f}.")
|
||||
found_files.append(fs.get_file(rootPath + f, fileclasses=fileclasses))
|
||||
else:
|
||||
logging.debug(f"Filtering: {f}")
|
||||
found_files = [f for f in found_files if f is not None]
|
||||
# In some cases, directories can be considered as files by dupeGuru, which is
|
||||
# why we have this line below. In fact, there only one case: Bundle files under
|
||||
|
@ -56,7 +56,7 @@ class ExcludeListDialogCore:
|
||||
matched = False
|
||||
for row in self.exclude_list_table.rows:
|
||||
compiled_regex = self.exclude_list.get_compiled(row.regex)
|
||||
if compiled_regex and compiled_regex.match(test_string):
|
||||
if compiled_regex and compiled_regex.fullmatch(test_string):
|
||||
matched = True
|
||||
row.highlight = True
|
||||
else:
|
||||
|
@ -129,8 +129,7 @@ class ExcludeListDialog(QDialog):
|
||||
except re.error:
|
||||
self.reset_input_style()
|
||||
return
|
||||
match = compiled.match(input_text)
|
||||
if match:
|
||||
if compiled.fullmatch(input_text):
|
||||
self._input_styled = True
|
||||
self.inputLine.setStyleSheet("background-color: rgb(10, 200, 10);")
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user