forked from openkylin/ukui-search
[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 QMutex _mutex_doc_list_path;
|
||||
|
||||
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> list, IndexGenerator *parent)
|
||||
ConstructDocumentForPath::ConstructDocumentForPath(QVector<QString> 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();
|
||||
|
|
|
@ -31,28 +31,23 @@ class IndexGenerator;
|
|||
class ConstructDocumentForPath : public QRunnable
|
||||
{
|
||||
public:
|
||||
explicit ConstructDocumentForPath(QVector<QString> list,IndexGenerator *parent = nullptr);
|
||||
~ConstructDocumentForPath();
|
||||
explicit ConstructDocumentForPath(QVector<QString> list);
|
||||
~ConstructDocumentForPath() = default;
|
||||
protected:
|
||||
void run();
|
||||
private:
|
||||
QVector<QString> 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
|
||||
|
|
|
@ -160,7 +160,8 @@ void FirstIndex::run(){
|
|||
QtConcurrent::run([&](){
|
||||
sem.acquire(2);
|
||||
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()) {
|
||||
// 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){
|
||||
|
|
|
@ -63,7 +63,11 @@ bool IndexGenerator::setIndexdataPath()
|
|||
bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *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<QVector<QString> > *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<QString> *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<QVector<QString>> *messageList)
|
|||
// delete constructer;
|
||||
// constructer = nullptr;
|
||||
|
||||
|
||||
qDebug()<<_doc_list_path->size();
|
||||
// qDebug()<<_doc_list_path->size();
|
||||
// qWarning() << _doc_list_path;
|
||||
// QList<Document> docList = future.results();
|
||||
// m_doc_list_path = new QList<Document>(docList);
|
||||
// m_doc_list_path = std::move(future.results());
|
||||
|
@ -286,7 +294,9 @@ void IndexGenerator::HandlePathList(QQueue<QString> *messageList)
|
|||
|
||||
// QList<Document> docList = future.results();
|
||||
// m_doc_list_content = new QList<Document>(docList);
|
||||
qDebug()<<_doc_list_content->size();
|
||||
|
||||
// qDebug()<<_doc_list_content->size();
|
||||
|
||||
// QList<Document> docList = future.results();
|
||||
// m_doc_list_content = new QList<Document>(docList);
|
||||
// m_doc_list_content = std::move(future.results());
|
||||
|
|
|
@ -44,5 +44,5 @@ void UkuiSearchQDBus::setInotifyMaxUserWatches()
|
|||
// sysctl
|
||||
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2");
|
||||
// /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[])
|
||||
{
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue