diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index 1623145..d66b432 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -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,34 +541,36 @@ 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)) { - SearchPluginIface::ResultInfo ri; - if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) { - SearchManager::m_mutexDir.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) { - m_searchResult->enqueue(ri); - SearchManager::m_mutexDir.unlock(); - } else { - SearchManager::m_mutexDir.unlock(); - return; - } - } - } else if (i.isFile() && m_value == FILE_SEARCH_VALUE) { - SearchPluginIface::ResultInfo ri; - if(SearchManager::creatResultInfo(ri,i.absoluteFilePath())) { - SearchManager::m_mutexFile.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) { - m_searchResult->enqueue(ri); - SearchManager::m_mutexFile.unlock(); - } else { - SearchManager::m_mutexFile.unlock(); - return; - } - } + 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,info.absoluteFilePath())) { + SearchManager::m_mutexDir.lock(); + if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) { + m_searchResult->enqueue(ri); + SearchManager::m_mutexDir.unlock(); + } else { + SearchManager::m_mutexDir.unlock(); + return; + } + } + } else if (info.isFile() && m_value == FILE_SEARCH_VALUE) { + SearchPluginIface::ResultInfo ri; + if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) { + SearchManager::m_mutexFile.lock(); + if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) { + m_searchResult->enqueue(ri); + SearchManager::m_mutexFile.unlock(); + } else { + SearchManager::m_mutexFile.unlock(); + return; } } } diff --git a/libsearch/index/search-manager.h b/libsearch/index/search-manager.h index 1c263ce..4da74d3 100644 --- a/libsearch/index/search-manager.h +++ b/libsearch/index/search-manager.h @@ -161,6 +161,7 @@ public: protected: void run(); private: + void match(const QFileInfo& info); QString m_keyword; DataQueue* m_searchResult = nullptr; size_t m_uniqueSymbol;