Skip to content

Commit 21c64b2

Browse files
committed
A small bug fix in the file content check
1 parent 12a939b commit 21c64b2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

fdir.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,17 @@ def fuzzy_match(query, file_name, threshold=0.6):
122122
return ratio >= threshold
123123

124124
def check_file_content(p, val, case_sensitive):
125-
if not p.is_file(): return False
125+
if not p.is_file():
126+
return False
127+
search_val = val.lower() if not case_sensitive else val
126128
try:
127129
with open(p, "r", encoding="utf-8", errors="ignore") as f:
128130
for line in f:
129-
if not case_sensitive:
130-
if val.lower() in line.lower(): return True
131-
else:
132-
if val in line: return True
133-
except Exception:
134-
pass
131+
current_line = line.lower() if not case_sensitive else line
132+
if search_val in current_line:
133+
return True
134+
except (OSError, IOError):
135+
pass
135136
return False
136137

137138
def satisfies_criteria(path_name, stat_info, op, flag, value, ignore, case_sensitive, fuzzy, content_found):

0 commit comments

Comments
 (0)