From 031ce8bbd8e5fbd469fb3153fe8f62ff019a0bbe Mon Sep 17 00:00:00 2001 From: iaom Date: Tue, 4 Apr 2023 16:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B4=A2=E5=BC=95=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E9=87=87=E7=94=A8=E5=A2=9E=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=A3=80=E9=AA=8C=E6=93=8D=E4=BD=9C=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/batch-indexer.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libsearch/index/batch-indexer.cpp b/libsearch/index/batch-indexer.cpp index 6ced291..c2e9b81 100644 --- a/libsearch/index/batch-indexer.cpp +++ b/libsearch/index/batch-indexer.cpp @@ -122,10 +122,7 @@ void BatchIndexer::basicIndex() } filesNeedIndex = m_cache; qDebug() < indexTimes = basicDb.getIndexTimes(); qDebug() << indexTimes.size() << "documents recorded"; @@ -135,14 +132,15 @@ void BatchIndexer::basicIndex() filesNeedIndex.append(path); } } - if(!indexTimes.isEmpty()) { + if(m_mode == WorkMode::Update && !indexTimes.isEmpty()) { qDebug() << indexTimes.size() << "documents need remove."; for(std::string uniqueTerm : indexTimes.keys()) { basicDb.removeDocument(uniqueTerm); } basicDb.commit(); } - qDebug() << filesNeedIndex.size() << "files need update."; + + qDebug() << filesNeedIndex.size() << "files need index."; } uint allSize = filesNeedIndex.size(); Q_EMIT progress(IndexType::Basic, allSize, 0); @@ -203,8 +201,6 @@ void BatchIndexer::contentIndex() if(!contentDb.open()) { return; } - } - if(m_mode == WorkMode::Rebuild || m_mode == WorkMode::Add) { for(QString path : m_cache) { info.setFile(path); if(true == suffixMap[info.suffix()] && info.isFile()) { @@ -213,7 +209,7 @@ void BatchIndexer::contentIndex() } } } - } else if(m_mode == WorkMode::Update) { + } else if(m_mode == WorkMode::Update || m_mode == WorkMode::Add) { QMap indexTimes = contentDb.getIndexTimes(); qDebug() << indexTimes.size() << "documents recorded"; for(QString path : m_cache) { @@ -230,7 +226,7 @@ void BatchIndexer::contentIndex() } } } - if(!indexTimes.isEmpty()) { + if(m_mode == WorkMode::Update && !indexTimes.isEmpty()) { qDebug() << indexTimes.size() << "documents need remove"; for(std::string uniqueTerm : indexTimes.keys()) { contentDb.removeDocument(uniqueTerm); @@ -239,6 +235,7 @@ void BatchIndexer::contentIndex() } } + uint allSize = filesNeedIndex.size(); qDebug() << allSize << "files need content index."; Q_EMIT progress(IndexType::Contents, allSize, 0);