解决全局搜索中遍历搜索不能搜索到顶层文件夹的问题

This commit is contained in:
iaom 2023-04-21 11:22:41 +08:00
parent 80320ab9f2
commit 37e3de3cee
2 changed files with 32 additions and 28 deletions

View File

@ -507,6 +507,7 @@ void DirectSearch::run() {
if (!underBlock) {
blockList.append(DirWatcher::getDirWatcher()->blackListOfDir(path));
bfs.enqueue(path);
match(QFileInfo(path));
}
}
if (bfs.isEmpty()) {
@ -540,13 +541,17 @@ void DirectSearch::run() {
}
bfs.enqueue(i.absoluteFilePath());
}
if(i.fileName().contains(m_keyword, Qt::CaseInsensitive)) {
// qWarning() << i.fileName() << m_keyword;
// if(m_searchResult->length() > 49)
// return;
if((i.isDir() && m_value == DIR_SEARCH_VALUE)) {
match(i);
}
}
}
void DirectSearch::match(const QFileInfo &info)
{
if(info.fileName().contains(m_keyword, Qt::CaseInsensitive)) {
if((info.isDir() && m_value == DIR_SEARCH_VALUE)) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) {
if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) {
SearchManager::m_mutexDir.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) {
m_searchResult->enqueue(ri);
@ -556,9 +561,9 @@ void DirectSearch::run() {
return;
}
}
} else if (i.isFile() && m_value == FILE_SEARCH_VALUE) {
} else if (info.isFile() && m_value == FILE_SEARCH_VALUE) {
SearchPluginIface::ResultInfo ri;
if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) {
if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) {
SearchManager::m_mutexFile.lock();
if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) {
m_searchResult->enqueue(ri);
@ -570,8 +575,6 @@ void DirectSearch::run() {
}
}
}
}
}
}
bool FileMatchDecider::operator ()(const Xapian::Document &doc) const

View File

@ -161,6 +161,7 @@ public:
protected:
void run();
private:
void match(const QFileInfo& info);
QString m_keyword;
DataQueue<SearchPluginIface::ResultInfo>* m_searchResult = nullptr;
size_t m_uniqueSymbol;