[Fix]Index process may crash while system first boot;
Remove a dbus operation.
This commit is contained in:
parent
f666f8c7ca
commit
f32a89cd33
|
@ -27,16 +27,12 @@
|
||||||
//extern QList<Document> *_doc_list_path;
|
//extern QList<Document> *_doc_list_path;
|
||||||
//extern QMutex _mutex_doc_list_path;
|
//extern QMutex _mutex_doc_list_path;
|
||||||
|
|
||||||
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> list, IndexGenerator *parent)
|
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> list)
|
||||||
{
|
{
|
||||||
this->setAutoDelete(true);
|
this->setAutoDelete(true);
|
||||||
m_list = std::move(list);
|
m_list = std::move(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstructDocumentForPath::~ConstructDocumentForPath()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConstructDocumentForPath::run()
|
void ConstructDocumentForPath::run()
|
||||||
{
|
{
|
||||||
// qDebug()<<"ConstructDocumentForPath";
|
// qDebug()<<"ConstructDocumentForPath";
|
||||||
|
@ -103,17 +99,12 @@ void ConstructDocumentForPath::run()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstructDocumentForContent::ConstructDocumentForContent(QString path,QObject *parent)
|
ConstructDocumentForContent::ConstructDocumentForContent(QString path)
|
||||||
{
|
{
|
||||||
this->setAutoDelete(true);
|
this->setAutoDelete(true);
|
||||||
m_path = std::move(path);
|
m_path = std::move(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstructDocumentForContent::~ConstructDocumentForContent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConstructDocumentForContent::run()
|
void ConstructDocumentForContent::run()
|
||||||
{
|
{
|
||||||
// qDebug() << "ConstructDocumentForContent currentThreadId()" << QThread::currentThreadId();
|
// qDebug() << "ConstructDocumentForContent currentThreadId()" << QThread::currentThreadId();
|
||||||
|
|
|
@ -31,28 +31,23 @@ class IndexGenerator;
|
||||||
class ConstructDocumentForPath : public QRunnable
|
class ConstructDocumentForPath : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ConstructDocumentForPath(QVector<QString> list,IndexGenerator *parent = nullptr);
|
explicit ConstructDocumentForPath(QVector<QString> list);
|
||||||
~ConstructDocumentForPath();
|
~ConstructDocumentForPath() = default;
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
private:
|
private:
|
||||||
QVector<QString> m_list;
|
QVector<QString> m_list;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstructDocumentForContent : public QObject, public QRunnable
|
class ConstructDocumentForContent : public QRunnable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
explicit ConstructDocumentForContent(QString path,QObject *parent = nullptr);
|
explicit ConstructDocumentForContent(QString path);
|
||||||
~ConstructDocumentForContent();
|
~ConstructDocumentForContent() = default;
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
private:
|
private:
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONSTRUCTDOCUMENT_H
|
#endif // CONSTRUCTDOCUMENT_H
|
||||||
|
|
|
@ -160,7 +160,8 @@ void FirstIndex::run(){
|
||||||
QtConcurrent::run([&](){
|
QtConcurrent::run([&](){
|
||||||
sem.acquire(2);
|
sem.acquire(2);
|
||||||
mutex3.unlock();
|
mutex3.unlock();
|
||||||
QQueue<QString>* tmp = new QQueue<QString>();;
|
QQueue<QString>* tmp = new QQueue<QString>();
|
||||||
|
qDebug()<<"q_content_index:"<<q_content_index->size();
|
||||||
while (!this->q_content_index->empty()) {
|
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 < this->u_send_length) && (!this->q_content_index->empty()); ++i){
|
||||||
for (size_t i = 0; (i < 30) && (!this->q_content_index->empty()); ++i){
|
for (size_t i = 0; (i < 30) && (!this->q_content_index->empty()); ++i){
|
||||||
|
|
|
@ -63,7 +63,11 @@ bool IndexGenerator::setIndexdataPath()
|
||||||
bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
|
bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
|
||||||
{
|
{
|
||||||
// FileUtils::_index_status |= 0x1;
|
// FileUtils::_index_status |= 0x1;
|
||||||
|
// qDebug() << messageList->size();
|
||||||
HandlePathList(messageList);
|
HandlePathList(messageList);
|
||||||
|
if (_doc_list_path == NULL){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
qDebug()<<"begin creatAllIndex";
|
qDebug()<<"begin creatAllIndex";
|
||||||
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
|
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
|
||||||
try
|
try
|
||||||
|
@ -75,6 +79,7 @@ bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
|
||||||
// m_indexer.set_stemming_strategy(Xapian::TermGenerator::STEM_SOME);
|
// m_indexer.set_stemming_strategy(Xapian::TermGenerator::STEM_SOME);
|
||||||
|
|
||||||
// int count =0;
|
// int count =0;
|
||||||
|
|
||||||
for (auto i : *_doc_list_path){
|
for (auto i : *_doc_list_path){
|
||||||
|
|
||||||
insertIntoDatabase(i);
|
insertIntoDatabase(i);
|
||||||
|
@ -107,6 +112,9 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
|
||||||
// FileUtils::_index_status |= 0x2;
|
// FileUtils::_index_status |= 0x2;
|
||||||
HandlePathList(messageList);
|
HandlePathList(messageList);
|
||||||
qDebug()<<"begin creatAllIndex for content";
|
qDebug()<<"begin creatAllIndex for content";
|
||||||
|
if (_doc_list_content == NULL){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int size = _doc_list_content->size();
|
int size = _doc_list_content->size();
|
||||||
if(!size == 0)
|
if(!size == 0)
|
||||||
{
|
{
|
||||||
|
@ -247,8 +255,8 @@ void IndexGenerator::HandlePathList(QQueue<QVector<QString>> *messageList)
|
||||||
// delete constructer;
|
// delete constructer;
|
||||||
// constructer = nullptr;
|
// constructer = nullptr;
|
||||||
|
|
||||||
|
// qDebug()<<_doc_list_path->size();
|
||||||
qDebug()<<_doc_list_path->size();
|
// qWarning() << _doc_list_path;
|
||||||
// QList<Document> docList = future.results();
|
// QList<Document> docList = future.results();
|
||||||
// m_doc_list_path = new QList<Document>(docList);
|
// m_doc_list_path = new QList<Document>(docList);
|
||||||
// m_doc_list_path = std::move(future.results());
|
// m_doc_list_path = std::move(future.results());
|
||||||
|
@ -286,7 +294,9 @@ void IndexGenerator::HandlePathList(QQueue<QString> *messageList)
|
||||||
|
|
||||||
// QList<Document> docList = future.results();
|
// QList<Document> docList = future.results();
|
||||||
// m_doc_list_content = new QList<Document>(docList);
|
// m_doc_list_content = new QList<Document>(docList);
|
||||||
qDebug()<<_doc_list_content->size();
|
|
||||||
|
// qDebug()<<_doc_list_content->size();
|
||||||
|
|
||||||
// QList<Document> docList = future.results();
|
// QList<Document> docList = future.results();
|
||||||
// m_doc_list_content = new QList<Document>(docList);
|
// m_doc_list_content = new QList<Document>(docList);
|
||||||
// m_doc_list_content = std::move(future.results());
|
// m_doc_list_content = std::move(future.results());
|
||||||
|
|
|
@ -44,5 +44,5 @@ void UkuiSearchQDBus::setInotifyMaxUserWatches()
|
||||||
// sysctl
|
// sysctl
|
||||||
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2");
|
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2");
|
||||||
// /etc/sysctl.conf
|
// /etc/sysctl.conf
|
||||||
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3");
|
// this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep3");
|
||||||
}
|
}
|
||||||
|
|
22
src/main.cpp
22
src/main.cpp
|
@ -124,6 +124,27 @@ void centerToScreen(QWidget* widget) {
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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);
|
unlink(UKUI_SEARCH_PIPE_PATH);
|
||||||
int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777);
|
int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777);
|
||||||
if(retval == -1)
|
if(retval == -1)
|
||||||
|
@ -247,6 +268,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// FirstIndex fi("/home/zhangzihao/Desktop/qwerty");
|
// FirstIndex fi("/home/zhangzihao/Desktop/qwerty");
|
||||||
// FirstIndex* fi = new FirstIndex("/home/zhangzihao/Desktop/qwerty");
|
// FirstIndex* fi = new FirstIndex("/home/zhangzihao/Desktop/qwerty");
|
||||||
|
|
||||||
FirstIndex fi("/home/zhangzihao/Desktop");
|
FirstIndex fi("/home/zhangzihao/Desktop");
|
||||||
fi.start();
|
fi.start();
|
||||||
// fi.wait();
|
// fi.wait();
|
||||||
|
|
Loading…
Reference in New Issue