fix(interface):开关索引后索引状态没有实时改变,stop和idle信号发送顺序有误.
This commit is contained in:
parent
2218c36b49
commit
fda1cd4f08
|
@ -119,6 +119,11 @@ void BatchIndexer::fetch()
|
||||||
dir.setPath(bfs.dequeue());
|
dir.setPath(bfs.dequeue());
|
||||||
list = dir.entryInfoList();
|
list = dir.entryInfoList();
|
||||||
for(const auto& i : list) {
|
for(const auto& i : list) {
|
||||||
|
if(m_indexStop->LOAD && m_contentIndexStop->LOAD && m_contentIndexOcrStop->LOAD && m_aiIndexStop->LOAD) {
|
||||||
|
qDebug() << "Index stopped, abort index from traversal.";
|
||||||
|
m_cache.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool isBlocked = false;
|
bool isBlocked = false;
|
||||||
for(const QString &path : tmpList) {
|
for(const QString &path : tmpList) {
|
||||||
if(i.absoluteFilePath() == path) {
|
if(i.absoluteFilePath() == path) {
|
||||||
|
@ -142,6 +147,11 @@ void BatchIndexer::fetch()
|
||||||
void BatchIndexer::basicIndex()
|
void BatchIndexer::basicIndex()
|
||||||
{
|
{
|
||||||
qDebug() << "Begin basic index";
|
qDebug() << "Begin basic index";
|
||||||
|
if(m_indexStop->LOAD) {
|
||||||
|
qDebug() << "Index stopped, abort basic index.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WritableDatabase basicDb(DataBaseType::Basic);
|
WritableDatabase basicDb(DataBaseType::Basic);
|
||||||
if(!basicDb.open()) {
|
if(!basicDb.open()) {
|
||||||
qWarning() << "Basic db open failed, fail to run basic index!";
|
qWarning() << "Basic db open failed, fail to run basic index!";
|
||||||
|
@ -183,6 +193,12 @@ void BatchIndexer::basicIndex()
|
||||||
uint batchSize = 0;
|
uint batchSize = 0;
|
||||||
uint finishNum = 0;
|
uint finishNum = 0;
|
||||||
for (const QString& path: filesNeedIndex) {
|
for (const QString& path: filesNeedIndex) {
|
||||||
|
if(m_indexStop->LOAD) {
|
||||||
|
basicDb.commit();
|
||||||
|
qDebug() << "Index stopped, interrupt basic index.";
|
||||||
|
filesNeedIndex.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
BasicIndexer indexer(path);
|
BasicIndexer indexer(path);
|
||||||
if(indexer.index()) {
|
if(indexer.index()) {
|
||||||
basicDb.addDocument(indexer.document());
|
basicDb.addDocument(indexer.document());
|
||||||
|
@ -193,12 +209,6 @@ void BatchIndexer::basicIndex()
|
||||||
qDebug() << finishNum << "of" << allSize <<"finished.";
|
qDebug() << finishNum << "of" << allSize <<"finished.";
|
||||||
basicDb.commit();
|
basicDb.commit();
|
||||||
Q_EMIT progress(IndexType::Basic, allSize, finishNum);
|
Q_EMIT progress(IndexType::Basic, allSize, finishNum);
|
||||||
//文件名索引很快
|
|
||||||
if(m_indexStop->LOAD) {
|
|
||||||
qDebug() << "Index stopped, abort basic index.";
|
|
||||||
filesNeedIndex.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
batchSize = 0;
|
batchSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,7 @@ void IndexScheduler::batchIndexerFinished(BatchIndexer::WorkMode mode, BatchInde
|
||||||
if(mode == BatchIndexer::WorkMode::Add) {
|
if(mode == BatchIndexer::WorkMode::Add) {
|
||||||
m_addNewPathPendingWorkCount--;
|
m_addNewPathPendingWorkCount--;
|
||||||
}
|
}
|
||||||
if(isIdle()) {
|
if (isIdle() && m_state != Stop) {
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
Q_EMIT stateChange(m_state);
|
Q_EMIT stateChange(m_state);
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ void IndexScheduler::batchIndexerFinished(BatchIndexer::WorkMode mode, BatchInde
|
||||||
void IndexScheduler::updateFinished()
|
void IndexScheduler::updateFinished()
|
||||||
{
|
{
|
||||||
m_updatePendingWorkCount--;
|
m_updatePendingWorkCount--;
|
||||||
if(isIdle()) {
|
if (isIdle() && m_state != Stop) {
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
Q_EMIT stateChange(m_state);
|
Q_EMIT stateChange(m_state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include <QApplication>
|
||||||
#include "file-indexer-config.h"
|
#include "file-indexer-config.h"
|
||||||
using namespace UkuiSearch;
|
using namespace UkuiSearch;
|
||||||
Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) : MonitorSource(parent),
|
Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) : MonitorSource(parent),
|
||||||
|
@ -163,6 +164,7 @@ void Monitor::onIndexStateChanged(IndexScheduler::IndexerState state)
|
||||||
}
|
}
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<IndexScheduler::IndexerState>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<IndexScheduler::IndexerState>();
|
||||||
Q_EMIT indexStateChanged(QString::fromLocal8Bit(metaEnum.valueToKey(state)));
|
Q_EMIT indexStateChanged(QString::fromLocal8Bit(metaEnum.valueToKey(state)));
|
||||||
|
QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::processUpdate(IndexType type, uint all, uint finished)
|
void Monitor::processUpdate(IndexType type, uint all, uint finished)
|
||||||
|
|
Loading…
Reference in New Issue