forked from openkylin/ukui-search
增加索引目录时采用增量更新检验操作,避免重复索引
This commit is contained in:
parent
7e670163fa
commit
031ce8bbd8
|
@ -122,10 +122,7 @@ void BatchIndexer::basicIndex()
|
||||||
}
|
}
|
||||||
filesNeedIndex = m_cache;
|
filesNeedIndex = m_cache;
|
||||||
qDebug() <<filesNeedIndex.size() << "files need index.";
|
qDebug() <<filesNeedIndex.size() << "files need index.";
|
||||||
} else if(m_mode == WorkMode::Add) {
|
} else if (m_mode == WorkMode::Update || m_mode == WorkMode::Add) {
|
||||||
filesNeedIndex = m_cache;
|
|
||||||
qDebug() <<filesNeedIndex.size() << "files need index.";
|
|
||||||
} else if (m_mode == WorkMode::Update) {
|
|
||||||
QFileInfo info;
|
QFileInfo info;
|
||||||
QMap<std::string, std::string> indexTimes = basicDb.getIndexTimes();
|
QMap<std::string, std::string> indexTimes = basicDb.getIndexTimes();
|
||||||
qDebug() << indexTimes.size() << "documents recorded";
|
qDebug() << indexTimes.size() << "documents recorded";
|
||||||
|
@ -135,14 +132,15 @@ void BatchIndexer::basicIndex()
|
||||||
filesNeedIndex.append(path);
|
filesNeedIndex.append(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!indexTimes.isEmpty()) {
|
if(m_mode == WorkMode::Update && !indexTimes.isEmpty()) {
|
||||||
qDebug() << indexTimes.size() << "documents need remove.";
|
qDebug() << indexTimes.size() << "documents need remove.";
|
||||||
for(std::string uniqueTerm : indexTimes.keys()) {
|
for(std::string uniqueTerm : indexTimes.keys()) {
|
||||||
basicDb.removeDocument(uniqueTerm);
|
basicDb.removeDocument(uniqueTerm);
|
||||||
}
|
}
|
||||||
basicDb.commit();
|
basicDb.commit();
|
||||||
}
|
}
|
||||||
qDebug() << filesNeedIndex.size() << "files need update.";
|
|
||||||
|
qDebug() << filesNeedIndex.size() << "files need index.";
|
||||||
}
|
}
|
||||||
uint allSize = filesNeedIndex.size();
|
uint allSize = filesNeedIndex.size();
|
||||||
Q_EMIT progress(IndexType::Basic, allSize, 0);
|
Q_EMIT progress(IndexType::Basic, allSize, 0);
|
||||||
|
@ -203,8 +201,6 @@ void BatchIndexer::contentIndex()
|
||||||
if(!contentDb.open()) {
|
if(!contentDb.open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(m_mode == WorkMode::Rebuild || m_mode == WorkMode::Add) {
|
|
||||||
for(QString path : m_cache) {
|
for(QString path : m_cache) {
|
||||||
info.setFile(path);
|
info.setFile(path);
|
||||||
if(true == suffixMap[info.suffix()] && info.isFile()) {
|
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<std::string, std::string> indexTimes = contentDb.getIndexTimes();
|
QMap<std::string, std::string> indexTimes = contentDb.getIndexTimes();
|
||||||
qDebug() << indexTimes.size() << "documents recorded";
|
qDebug() << indexTimes.size() << "documents recorded";
|
||||||
for(QString path : m_cache) {
|
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";
|
qDebug() << indexTimes.size() << "documents need remove";
|
||||||
for(std::string uniqueTerm : indexTimes.keys()) {
|
for(std::string uniqueTerm : indexTimes.keys()) {
|
||||||
contentDb.removeDocument(uniqueTerm);
|
contentDb.removeDocument(uniqueTerm);
|
||||||
|
@ -239,6 +235,7 @@ void BatchIndexer::contentIndex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint allSize = filesNeedIndex.size();
|
uint allSize = filesNeedIndex.size();
|
||||||
qDebug() << allSize << "files need content index.";
|
qDebug() << allSize << "files need content index.";
|
||||||
Q_EMIT progress(IndexType::Contents, allSize, 0);
|
Q_EMIT progress(IndexType::Contents, allSize, 0);
|
||||||
|
|
Loading…
Reference in New Issue