From d216398c82acc6486b77350d5a72c0bb66b87fa2 Mon Sep 17 00:00:00 2001 From: iaom <18504285112@163.com> Date: Tue, 7 Sep 2021 17:11:23 +0800 Subject: [PATCH] Fix: Index error when process a whole dir. --- libsearch/index/construct-document.cpp | 6 +++--- libsearch/index/index-generator.cpp | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libsearch/index/construct-document.cpp b/libsearch/index/construct-document.cpp index 445bdb5..1b1f4eb 100644 --- a/libsearch/index/construct-document.cpp +++ b/libsearch/index/construct-document.cpp @@ -54,12 +54,12 @@ void ConstructDocumentForPath::run() { // } QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath)); - QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath.section("/", 0, -2, QString::SectionIncludeLeadingSep))); + QString upTerm = QString::fromStdString("ZEEKERUPTERM" + FileUtils::makeDocUterm(sourcePath.section("/", 0, -2, QString::SectionIncludeLeadingSep))); // qDebug()<<"sourcePath"<isEmpty()) return true; try { + qDebug() << "--delete start--"; for(int i = 0; i < list->size(); i++) { QString doc = list->at(i); std::string uniqueterm = FileUtils::makeDocUterm(doc); - qDebug() << "--delete start--"; + std::string upterm = "ZEEKERUPTERM" + FileUtils::makeDocUterm(doc); + m_database_path->delete_document(uniqueterm); m_database_content->delete_document(uniqueterm); + + //delete all files under it if it's a dir. + m_database_path->delete_document(upterm); + m_database_content->delete_document(upterm); qDebug() << "delete path" << doc; - qDebug() << "delete md5" << QString::fromStdString(uniqueterm); - qDebug() << "--delete finish--"; +// qDebug() << "delete md5" << QString::fromStdString(uniqueterm); + // qDebug()<<"m_database_path->get_lastdocid()!!!"<get_lastdocid(); // qDebug()<<"m_database_path->get_doccount()!!!"<get_doccount(); } m_database_path->commit(); m_database_content->commit(); + qDebug() << "--delete finish--"; } catch(const Xapian::Error &e) { qWarning() << QString::fromStdString(e.get_description()); return false;