diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index 2c6e692..3d99dbe 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -33,7 +33,7 @@ public: static void getDocxTextContent(QString &path, QString &textcontent); static void getTxtContent(QString &path, QString &textcontent); static size_t _max_index_count; - static size_t _current_index_count; + static size_t _current_index_count; //this one has been Abandoned,do not use it. static unsigned short _index_status; private: diff --git a/libsearch/index/file-searcher.cpp b/libsearch/index/file-searcher.cpp index d797d3d..e469915 100644 --- a/libsearch/index/file-searcher.cpp +++ b/libsearch/index/file-searcher.cpp @@ -20,6 +20,12 @@ FileSearcher::~FileSearcher() { } +int FileSearcher::getCurrentIndexCount() +{ + Xapian::Database db(INDEX_PATH); + return db.get_doccount(); +} + void FileSearcher::onKeywordSearch(QString keyword,QQueue *searchResultFile,QQueue *searchResultDir,QQueue> *searchResultContent) { m_mutex1.lock(); diff --git a/libsearch/index/file-searcher.h b/libsearch/index/file-searcher.h index d6a1a8f..22008e8 100644 --- a/libsearch/index/file-searcher.h +++ b/libsearch/index/file-searcher.h @@ -20,6 +20,8 @@ public: explicit FileSearcher(QObject *parent = nullptr); ~FileSearcher(); + int getCurrentIndexCount(); + static size_t uniqueSymbol1; static size_t uniqueSymbol2; static size_t uniqueSymbol3; diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index 3dc3c39..7d1fee8 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -56,7 +56,6 @@ bool IndexGenerator::creatAllIndex(QQueue > *messageList) count = 0; m_datebase_path->commit(); } - FileUtils::_current_index_count += 1; } m_datebase_path->commit(); } @@ -65,7 +64,7 @@ bool IndexGenerator::creatAllIndex(QQueue > *messageList) qWarning()<<"creatAllIndex fail!"<setValue(INDEX_DATABASE_STATE,"1"); - Q_ASSERT(false); + assert(false); } m_doc_list_path->clear(); Q_EMIT this->transactionFinished(); @@ -96,7 +95,7 @@ bool IndexGenerator::creatAllIndex(QQueue *messageList) { qWarning()<<"creat content Index fail!"<setValue(CONTENT_INDEX_DATABASE_STATE,"1"); - Q_ASSERT(false); + assert(false); } m_doc_list_content->clear(); Q_EMIT this->transactionFinished(); @@ -361,9 +360,6 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist) qDebug()<<"delete path"<commit(); - - FileUtils::_current_index_count = m_datebase_path->get_doccount(); - qDebug()<< "--delete finish--"; } catch(const Xapian::Error &e)