From 37e3de3cee58399de341e79ec0323ddb4491beca Mon Sep 17 00:00:00 2001 From: iaom Date: Fri, 21 Apr 2023 11:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=85=A8=E5=B1=80=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=B8=AD=E9=81=8D=E5=8E=86=E6=90=9C=E7=B4=A2=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=90=9C=E7=B4=A2=E5=88=B0=E9=A1=B6=E5=B1=82=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/search-manager.cpp | 59 ++++++++++++++++-------------- libsearch/index/search-manager.h | 1 + 2 files changed, 32 insertions(+), 28 deletions(-) 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;