From cacf2b8fc81ec3e92656f9990bc2becfb916d39b Mon Sep 17 00:00:00 2001 From: iaom Date: Thu, 28 Apr 2022 14:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=B4=A2=E5=BC=95=E7=9B=AE=E5=BD=95=E5=90=8E?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E7=9A=84=E5=86=85=E5=AE=B9=E6=90=9C=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E7=9A=84bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/first-index.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libsearch/index/first-index.cpp b/libsearch/index/first-index.cpp index 2ae1720..4198084 100644 --- a/libsearch/index/first-index.cpp +++ b/libsearch/index/first-index.cpp @@ -22,6 +22,11 @@ #include "first-index.h" #include "dir-watcher.h" #include +/*需要重构: + *支持新建或重建指定目录索引 + *支持判断所有数据库状态,根据状态判断是否单独重建某个数据库。 + *支持自定义增加索引目录。 + */ using namespace UkuiSearch; FirstIndex *FirstIndex::m_instance = nullptr; @@ -124,7 +129,6 @@ void FirstIndex::addIndexPath(const QString path, const QStringList blockList) void FirstIndex::run() { QTime t1 = QTime::currentTime(); - // Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running. QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString(); QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString(); // QString ocrIndexDatabaseStatus = IndexStatusRecorder::getInstance()->getStatus(OCR_DATABASE_STATE).toString(); @@ -187,8 +191,11 @@ void FirstIndex::run() { sem.release(2); return; } + if (!m_allDatadaseStatus || !m_indexDatabaseStatus || !m_contentIndexDatabaseStatus) { + IndexGenerator::getInstance()->rebuildIndexDatabase(); + } qDebug() << "index start;" << m_indexData->size(); - IndexGenerator::getInstance()->rebuildIndexDatabase(); + QQueue>* tmp1 = new QQueue>(); bool sucess = true; while(!this->m_indexData->empty()) { @@ -215,8 +222,10 @@ void FirstIndex::run() { sem.release(2); return; } + if (!m_allDatadaseStatus || !m_contentIndexDatabaseStatus || !m_indexDatabaseStatus) { + IndexGenerator::getInstance()->rebuildContentIndexDatabase(); + } qDebug() << "content index start:" << m_contentIndexData->size(); - IndexGenerator::getInstance()->rebuildContentIndexDatabase(); QQueue* tmp2 = new QQueue(); bool sucess = true; while(!this->m_contentIndexData->empty()) {