[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,14 +45,19 @@ void ConstructDocumentForPath::run()
|
||||||
// qDebug()<<_doc_list_path->size();
|
// qDebug()<<_doc_list_path->size();
|
||||||
QString index_text = m_list.at(0);
|
QString index_text = m_list.at(0);
|
||||||
QString sourcePath = m_list.at(1);
|
QString sourcePath = m_list.at(1);
|
||||||
|
Document doc;
|
||||||
|
|
||||||
//多音字版
|
//多音字版
|
||||||
//现加入首字母
|
//现加入首字母
|
||||||
QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(m_list.at(0)).replace(".",""));
|
QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(m_list.at(0)).replace(".",""));
|
||||||
|
if(!pinyin_text_list.isEmpty())
|
||||||
|
{
|
||||||
for (QString& i : pinyin_text_list){
|
for (QString& i : pinyin_text_list){
|
||||||
i.replace("", " ");
|
i.replace("", " ");
|
||||||
i = i.simplified();
|
i = i.simplified();
|
||||||
}
|
}
|
||||||
|
doc.setIndexText(pinyin_text_list);
|
||||||
|
}
|
||||||
|
|
||||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
||||||
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath.section("/",0,-2,QString::SectionIncludeLeadingSep)));
|
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath.section("/",0,-2,QString::SectionIncludeLeadingSep)));
|
||||||
|
@ -62,7 +67,7 @@ void ConstructDocumentForPath::run()
|
||||||
// qDebug() << "ConstructDocumentForPath -- uniqueterm: " << uniqueterm;
|
// qDebug() << "ConstructDocumentForPath -- uniqueterm: " << uniqueterm;
|
||||||
// qDebug() << "ConstructDocumentForPath -- upTerm: " << upTerm;
|
// qDebug() << "ConstructDocumentForPath -- upTerm: " << upTerm;
|
||||||
|
|
||||||
Document doc;
|
|
||||||
doc.setData(sourcePath);
|
doc.setData(sourcePath);
|
||||||
doc.setUniqueTerm(uniqueterm);
|
doc.setUniqueTerm(uniqueterm);
|
||||||
doc.addTerm(upTerm);
|
doc.addTerm(upTerm);
|
||||||
|
@ -70,7 +75,6 @@ void ConstructDocumentForPath::run()
|
||||||
/* QStringList temp;
|
/* QStringList temp;
|
||||||
// temp.append(index_text);
|
// temp.append(index_text);
|
||||||
temp.append(pinyin_text_list)*/;
|
temp.append(pinyin_text_list)*/;
|
||||||
doc.setIndexText(pinyin_text_list);
|
|
||||||
int postingCount = 0;
|
int postingCount = 0;
|
||||||
while(postingCount < index_text.size())
|
while(postingCount < index_text.size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,9 +200,11 @@ void IndexGenerator::insertIntoDatabase(Document& doc)
|
||||||
for(auto i : doc.getIndexText()){
|
for(auto i : doc.getIndexText()){
|
||||||
m_indexer.index_text(i.toStdString());
|
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);
|
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--";
|
// qDebug()<< "--index finish--";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,13 +163,9 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
||||||
qDebug() << QString(currentPath[event->wd] + '/' + event->name);
|
qDebug() << QString(currentPath[event->wd] + '/' + event->name);
|
||||||
// switch (event->mask) {
|
// switch (event->mask) {
|
||||||
if (event->mask & IN_CREATE){
|
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")));
|
// 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"));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event->mask & IN_ISDIR){
|
||||||
|
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||||
|
setPath(currentPath[event->wd] + '/' + event->name);
|
||||||
|
Traverse();
|
||||||
|
}
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,9 +225,7 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
||||||
if (event->mask & IN_ISDIR){
|
if (event->mask & IN_ISDIR){
|
||||||
RemoveWatch(currentPath[event->wd] + '/' + event->name);
|
RemoveWatch(currentPath[event->wd] + '/' + event->name);
|
||||||
// IndexGenerator::getInstance()->deleteAllIndex(new QStringList(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"));
|
indexQueue->enqueue(QVector<QString>() << QString(event->name) << QString(currentPath[event->wd] + '/' + event->name) << QString((event->mask & IN_ISDIR) ? "1" : "0"));
|
||||||
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
|
IndexGenerator::getInstance()->creatAllIndex(indexQueue);
|
||||||
|
@ -238,6 +238,11 @@ void InotifyIndex::eventProcess(const char* buf, ssize_t tmp){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddWatch(currentPath[event->wd] + '/' + event->name);
|
||||||
|
setPath(currentPath[event->wd] + '/' + event->name);
|
||||||
|
Traverse();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
|
IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name));
|
||||||
|
|
Loading…
Reference in New Issue