mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34: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 = []
|
found_files = []
|
||||||
# print(f"len of files: {len(files)} {files}")
|
# print(f"len of files: {len(files)} {files}")
|
||||||
for f in files:
|
for f in files:
|
||||||
found = False
|
matched = False
|
||||||
for expr in self._exclude_list.compiled_files:
|
for expr in self._exclude_list.compiled_files:
|
||||||
if expr.match(f):
|
if expr.fullmatch(f):
|
||||||
found = True
|
logging.debug(f"{expr} matched {f}.")
|
||||||
|
matched = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not matched:
|
||||||
|
logging.debug(f"path {root + os.sep + f}")
|
||||||
for expr in self._exclude_list.compiled_paths:
|
for expr in self._exclude_list.compiled_paths:
|
||||||
if expr.match(root + os.sep + f):
|
if expr.fullmatch(root + os.sep + f):
|
||||||
found = True
|
print(f"{expr} matched {root}{os.sep}{f}.")
|
||||||
|
matched = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not matched:
|
||||||
|
logging.debug(f"Not filtering: {f}.")
|
||||||
found_files.append(fs.get_file(rootPath + f, fileclasses=fileclasses))
|
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]
|
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
|
# 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
|
# why we have this line below. In fact, there only one case: Bundle files under
|
||||||
|
@ -56,7 +56,7 @@ class ExcludeListDialogCore:
|
|||||||
matched = False
|
matched = False
|
||||||
for row in self.exclude_list_table.rows:
|
for row in self.exclude_list_table.rows:
|
||||||
compiled_regex = self.exclude_list.get_compiled(row.regex)
|
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
|
matched = True
|
||||||
row.highlight = True
|
row.highlight = True
|
||||||
else:
|
else:
|
||||||
|
@ -129,8 +129,7 @@ class ExcludeListDialog(QDialog):
|
|||||||
except re.error:
|
except re.error:
|
||||||
self.reset_input_style()
|
self.reset_input_style()
|
||||||
return
|
return
|
||||||
match = compiled.match(input_text)
|
if compiled.fullmatch(input_text):
|
||||||
if match:
|
|
||||||
self._input_styled = True
|
self._input_styled = True
|
||||||
self.inputLine.setStyleSheet("background-color: rgb(10, 200, 10);")
|
self.inputLine.setStyleSheet("background-color: rgb(10, 200, 10);")
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user