forked from openkylin/ukui-search
[FIX] File index won't be created correctly when copied a folder which has many childern folders.
This commit is contained in:
parent
7289562d17
commit
81cf59cd3c
|
@ -45,13 +45,18 @@ void ConstructDocumentForPath::run()
|
|||
// qDebug()<<_doc_list_path->size();
|
||||
QString index_text = m_list.at(0);
|
||||
QString sourcePath = m_list.at(1);
|
||||
Document doc;
|
||||
|
||||
//多音字版
|
||||
//现加入首字母
|
||||
QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(m_list.at(0)).replace(".",""));
|
||||
for (QString& i : pinyin_text_list){
|
||||
i.replace("", " ");
|
||||
i = i.simplified();
|
||||
if(!pinyin_text_list.isEmpty())
|
||||
{
|
||||
for (QString& i : pinyin_text_list){
|
||||
i.replace("", " ");
|
||||
i = i.simplified();
|
||||
}
|
||||
doc.setIndexText(pinyin_text_list);
|
||||
}
|
||||
|
||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
||||
|
@ -62,7 +67,7 @@ void ConstructDocumentForPath::run()
|
|||
// qDebug() << "ConstructDocumentForPath -- uniqueterm: " << uniqueterm;
|
||||
// qDebug() << "ConstructDocumentForPath -- upTerm: " << upTerm;
|
||||
|
||||
Document doc;
|
||||
|
||||
doc.setData(sourcePath);
|
||||
doc.setUniqueTerm(uniqueterm);
|
||||
doc.addTerm(upTerm);
|
||||
|
@ -70,7 +75,6 @@ void ConstructDocumentForPath::run()
|
|||
/* QStringList temp;
|
||||
// temp.append(index_text);
|
||||
temp.append(pinyin_text_list)*/;
|
||||
doc.setIndexText(pinyin_text_list);
|
||||
int postingCount = 0;
|
||||
while(postingCount < index_text.size())
|
||||
{
|
||||
|
|
|
@ -200,9 +200,11 @@ void IndexGenerator::insertIntoDatabase(Document& doc)
|
|||
for(auto i : doc.getIndexText()){
|
||||
m_indexer.index_text(i.toStdString());
|
||||
}
|
||||
qDebug()<<"insert m_database_path:"<<QString::fromStdString(document.get_data());
|
||||
qDebug()<<"document:"<<QString::fromStdString(document.get_description());
|
||||
|
||||
Xapian::docid innerId= m_database_path->replace_document(doc.getUniqueTerm(),document);
|
||||
// qDebug()<<"replace doc docid="<<static_cast<int>(innerId);
|
||||
qDebug()<<"replace doc docid="<<static_cast<int>(innerId);
|
||||
// qDebug()<< "--index finish--";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -163,13 +163,9 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
|||
qDebug() << QString(currentPath[event->wd] + '/' + event->name);
|
||||
// switch (event->mask) {
|
||||
if (event->mask & IN_CREATE){
|
||||
qDebug() << "IN_CREATE";
|
||||
if (event->mask & IN_ISDIR){
|
||||
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||
setPath(currentPath[event->wd] + '/' + event->name);
|
||||
Traverse();
|
||||
}
|
||||
|
||||
//Create top dir first, traverse it last.
|
||||
qDebug() << "IN_CREATE";
|
||||
/*--------------------------------*/
|
||||
// IndexGenerator::getInstance()->creatAllIndex(QQueue<QVector<QString>>(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0")));
|
||||
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
|
||||
|
@ -183,6 +179,12 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (event->mask & IN_ISDIR){
|
||||
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||
setPath(currentPath[event->wd] + '/' + event->name);
|
||||
Traverse();
|
||||
}
|
||||
goto next;
|
||||
}
|
||||
|
||||
|
@ -223,9 +225,7 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
|||
if (event->mask & IN_ISDIR){
|
||||
RemoveWatch(currentPath[event->wd] + '/' + event->name);
|
||||
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
|
||||
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||
setPath(currentPath[event->wd] + '/' + event->name);
|
||||
Traverse();
|
||||
|
||||
|
||||
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
|
||||
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
|
||||
|
@ -238,6 +238,11 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||
setPath(currentPath[event->wd] + '/' + event->name);
|
||||
Traverse();
|
||||
|
||||
}
|
||||
else {
|
||||
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
|
||||
|
|
Loading…
Reference in New Issue