修复了添加新的索引目录后可能会导致已经索引的内容搜不到的bug。

This commit is contained in:
iaom 2022-04-28 14:25:29 +08:00
parent 3f561c8ad7
commit cacf2b8fc8
1 changed files with 12 additions and 3 deletions

View File

@ -22,6 +22,11 @@
#include "first-index.h" #include "first-index.h"
#include "dir-watcher.h" #include "dir-watcher.h"
#include <QDebug> #include <QDebug>
/*需要重构:
*
*
*
*/
using namespace UkuiSearch; using namespace UkuiSearch;
FirstIndex *FirstIndex::m_instance = nullptr; FirstIndex *FirstIndex::m_instance = nullptr;
@ -124,7 +129,6 @@ void FirstIndex::addIndexPath(const QString path, const QStringList blockList)
void FirstIndex::run() { void FirstIndex::run() {
QTime t1 = QTime::currentTime(); 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 indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString();
QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString(); QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString();
// QString ocrIndexDatabaseStatus = IndexStatusRecorder::getInstance()->getStatus(OCR_DATABASE_STATE).toString(); // QString ocrIndexDatabaseStatus = IndexStatusRecorder::getInstance()->getStatus(OCR_DATABASE_STATE).toString();
@ -187,8 +191,11 @@ void FirstIndex::run() {
sem.release(2); sem.release(2);
return; return;
} }
if (!m_allDatadaseStatus || !m_indexDatabaseStatus || !m_contentIndexDatabaseStatus) {
IndexGenerator::getInstance()->rebuildIndexDatabase();
}
qDebug() << "index start;" << m_indexData->size(); qDebug() << "index start;" << m_indexData->size();
IndexGenerator::getInstance()->rebuildIndexDatabase();
QQueue<QVector<QString>>* tmp1 = new QQueue<QVector<QString>>(); QQueue<QVector<QString>>* tmp1 = new QQueue<QVector<QString>>();
bool sucess = true; bool sucess = true;
while(!this->m_indexData->empty()) { while(!this->m_indexData->empty()) {
@ -215,8 +222,10 @@ void FirstIndex::run() {
sem.release(2); sem.release(2);
return; return;
} }
if (!m_allDatadaseStatus || !m_contentIndexDatabaseStatus || !m_indexDatabaseStatus) {
IndexGenerator::getInstance()->rebuildContentIndexDatabase();
}
qDebug() << "content index start:" << m_contentIndexData->size(); qDebug() << "content index start:" << m_contentIndexData->size();
IndexGenerator::getInstance()->rebuildContentIndexDatabase();
QQueue<QString>* tmp2 = new QQueue<QString>(); QQueue<QString>* tmp2 = new QQueue<QString>();
bool sucess = true; bool sucess = true;
while(!this->m_contentIndexData->empty()) { while(!this->m_contentIndexData->empty()) {