diff --git a/libsearch/index/construct-document.cpp b/libsearch/index/construct-document.cpp index 5a0cdaa..2021fc2 100644 --- a/libsearch/index/construct-document.cpp +++ b/libsearch/index/construct-document.cpp @@ -27,16 +27,12 @@ //extern QList *_doc_list_path; //extern QMutex _mutex_doc_list_path; -ConstructDocumentForPath::ConstructDocumentForPath(QVector list, IndexGenerator *parent) +ConstructDocumentForPath::ConstructDocumentForPath(QVector list) { this->setAutoDelete(true); m_list = std::move(list); } -ConstructDocumentForPath::~ConstructDocumentForPath() -{ -} - void ConstructDocumentForPath::run() { // qDebug()<<"ConstructDocumentForPath"; @@ -103,17 +99,12 @@ void ConstructDocumentForPath::run() return; } -ConstructDocumentForContent::ConstructDocumentForContent(QString path,QObject *parent) +ConstructDocumentForContent::ConstructDocumentForContent(QString path) { this->setAutoDelete(true); m_path = std::move(path); } -ConstructDocumentForContent::~ConstructDocumentForContent() -{ - -} - void ConstructDocumentForContent::run() { // qDebug() << "ConstructDocumentForContent currentThreadId()" << QThread::currentThreadId(); diff --git a/libsearch/index/construct-document.h b/libsearch/index/construct-document.h index 6f77258..46fab04 100644 --- a/libsearch/index/construct-document.h +++ b/libsearch/index/construct-document.h @@ -31,28 +31,23 @@ class IndexGenerator; class ConstructDocumentForPath : public QRunnable { public: - explicit ConstructDocumentForPath(QVector list,IndexGenerator *parent = nullptr); - ~ConstructDocumentForPath(); + explicit ConstructDocumentForPath(QVector list); + ~ConstructDocumentForPath() = default; protected: void run(); private: QVector m_list; - - }; -class ConstructDocumentForContent : public QObject, public QRunnable +class ConstructDocumentForContent : public QRunnable { - Q_OBJECT public: - explicit ConstructDocumentForContent(QString path,QObject *parent = nullptr); - ~ConstructDocumentForContent(); + explicit ConstructDocumentForContent(QString path); + ~ConstructDocumentForContent() = default; protected: void run(); private: QString m_path; - - }; #endif // CONSTRUCTDOCUMENT_H diff --git a/libsearch/index/first-index.cpp b/libsearch/index/first-index.cpp index b840895..4d38903 100644 --- a/libsearch/index/first-index.cpp +++ b/libsearch/index/first-index.cpp @@ -160,7 +160,8 @@ void FirstIndex::run(){ QtConcurrent::run([&](){ sem.acquire(2); mutex3.unlock(); - QQueue* tmp = new QQueue();; + QQueue* tmp = new QQueue(); + qDebug()<<"q_content_index:"<size(); while (!this->q_content_index->empty()) { // for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){ for (size_t i = 0; (i < 30) && (!this->q_content_index->empty()); ++i){ diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index 5105058..35a325e 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -63,7 +63,11 @@ bool IndexGenerator::setIndexdataPath() bool IndexGenerator::creatAllIndex(QQueue > *messageList) { // FileUtils::_index_status |= 0x1; +// qDebug() << messageList->size(); HandlePathList(messageList); + if (_doc_list_path == NULL){ + return false; + } qDebug()<<"begin creatAllIndex"; GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0"); try @@ -75,6 +79,7 @@ bool IndexGenerator::creatAllIndex(QQueue > *messageList) // m_indexer.set_stemming_strategy(Xapian::TermGenerator::STEM_SOME); // int count =0; + for (auto i : *_doc_list_path){ insertIntoDatabase(i); @@ -107,6 +112,9 @@ bool IndexGenerator::creatAllIndex(QQueue *messageList) // FileUtils::_index_status |= 0x2; HandlePathList(messageList); qDebug()<<"begin creatAllIndex for content"; + if (_doc_list_content == NULL){ + return false; + } int size = _doc_list_content->size(); if(!size == 0) { @@ -247,8 +255,8 @@ void IndexGenerator::HandlePathList(QQueue> *messageList) // delete constructer; // constructer = nullptr; - - qDebug()<<_doc_list_path->size(); +// qDebug()<<_doc_list_path->size(); +// qWarning() << _doc_list_path; // QList docList = future.results(); // m_doc_list_path = new QList(docList); // m_doc_list_path = std::move(future.results()); @@ -286,7 +294,9 @@ void IndexGenerator::HandlePathList(QQueue *messageList) // QList docList = future.results(); // m_doc_list_content = new QList(docList); - qDebug()<<_doc_list_content->size(); + +// qDebug()<<_doc_list_content->size(); + // QList docList = future.results(); // m_doc_list_content = new QList(docList); // m_doc_list_content = std::move(future.results()); diff --git a/libsearch/index/ukui-search-qdbus.cpp b/libsearch/index/ukui-search-qdbus.cpp index 324c51e..ce39f37 100644 --- a/libsearch/index/ukui-search-qdbus.cpp +++ b/libsearch/index/ukui-search-qdbus.cpp @@ -44,5 +44,5 @@ void UkuiSearchQDBus::setInotifyMaxUserWatches() // sysctl this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2"); // /etc/sysctl.conf - this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3"); +// this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3"); } diff --git a/src/main.cpp b/src/main.cpp index 9551cdd..f1468df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,6 +124,27 @@ void centerToScreen(QWidget* widget) { int main(int argc, char *argv[]) { + char *p_home = NULL; + + unsigned int i = 0; + while(p_home == NULL) + { + ::sleep(1); + ++i; + p_home = getenv("HOME"); + if(i%5==0) + { + qWarning()<<"I can't find home! I'm done here!!"; + printf("I can't find home! I'm done here!!"); + } + } + p_home = NULL; + while(!QDir(QDir::homePath()).exists()) + { + qWarning()<<"Home not exits!!"; + printf("Home not exits!!"); + ::sleep(1); + } unlink(UKUI_SEARCH_PIPE_PATH); int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777); if(retval == -1) @@ -247,6 +268,7 @@ int main(int argc, char *argv[]) // FirstIndex fi("/home/zhangzihao/Desktop/qwerty"); // FirstIndex* fi = new FirstIndex("/home/zhangzihao/Desktop/qwerty"); + FirstIndex fi("/home/zhangzihao/Desktop"); fi.start(); // fi.wait();