fixed search

This commit is contained in:
Radek Davidek 2026-04-22 10:53:32 +02:00
parent 65a996bc29
commit d30944ebec

View File

@ -658,16 +658,20 @@ public class FileOperations {
for (File file : files) { for (File file : files) {
if (callback != null && callback.isCancelled()) return; if (callback != null && callback.isCancelled()) return;
try { try {
if (file.isDirectory()) { // Always check if current file/directory matches name pattern
if (maxDepth == -1 || currentDepth < maxDepth) {
searchRecursive(file, patternLower, filenameRegex, contentPattern, maxDepth, currentDepth + 1, searchArchives, caseSensitive, callback);
}
} else {
boolean nameMatched = true; boolean nameMatched = true;
if (patternLower != null && !patternLower.isEmpty()) { if (patternLower != null && !patternLower.isEmpty()) {
nameMatched = matchName(file.getName(), patternLower, filenameRegex, caseSensitive); nameMatched = matchName(file.getName(), patternLower, filenameRegex, caseSensitive);
} }
if (file.isDirectory()) {
if (nameMatched && (contentPattern == null)) {
callback.onFileFound(file, null);
}
if (maxDepth == -1 || currentDepth < maxDepth) {
searchRecursive(file, patternLower, filenameRegex, contentPattern, maxDepth, currentDepth + 1, searchArchives, caseSensitive, callback);
}
} else {
boolean contentMatched = true; boolean contentMatched = true;
if (nameMatched && contentPattern != null) { if (nameMatched && contentPattern != null) {
contentMatched = fileMatchesContent(file, contentPattern); contentMatched = fileMatchesContent(file, contentPattern);