2021-04-20 16:24:07 +08:00
|
|
|
#include "searchmethodmanager.h"
|
2021-04-30 16:28:50 +08:00
|
|
|
using namespace Zeeker;
|
2021-06-10 20:43:57 +08:00
|
|
|
SearchMethodManager::SearchMethodManager()
|
|
|
|
{
|
|
|
|
m_iw = InotifyWatch::getInstance(HOME_PATH);
|
|
|
|
}
|
|
|
|
|
2021-04-26 15:06:47 +08:00
|
|
|
void SearchMethodManager::searchMethod(FileUtils::SearchMethod sm) {
|
2021-04-20 16:24:07 +08:00
|
|
|
qWarning() << "searchMethod start: " << static_cast<int>(sm);
|
2021-04-26 15:06:47 +08:00
|
|
|
if(FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == sm) {
|
2021-04-20 16:24:07 +08:00
|
|
|
FileUtils::searchMethod = sm;
|
|
|
|
} else {
|
|
|
|
qWarning("enum class error!!!\n");
|
|
|
|
}
|
2021-04-26 15:06:47 +08:00
|
|
|
if(FileUtils::SearchMethod::INDEXSEARCH == sm && 0 == FileUtils::_index_status) {
|
2021-07-01 19:37:37 +08:00
|
|
|
|
|
|
|
// Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running.
|
|
|
|
QDir fifoDir = QDir(QDir::homePath() + "/.config/org.ukui/ukui-search");
|
|
|
|
if(!fifoDir.exists())
|
|
|
|
qDebug() << "create fifo path" << fifoDir.mkpath(fifoDir.absolutePath());
|
|
|
|
|
|
|
|
unlink(UKUI_SEARCH_PIPE_PATH);
|
|
|
|
int retval = mkfifo(UKUI_SEARCH_PIPE_PATH, 0777);
|
|
|
|
if(retval == -1) {
|
|
|
|
qCritical() << "creat fifo error!!";
|
|
|
|
syslog(LOG_ERR, "creat fifo error!!\n");
|
|
|
|
assert(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qDebug() << "create fifo success\n";
|
2021-04-20 16:24:07 +08:00
|
|
|
qWarning() << "start first index";
|
|
|
|
m_fi.start();
|
|
|
|
qWarning() << "start inotify index";
|
|
|
|
// InotifyIndex ii("/home");
|
|
|
|
// ii.start();
|
2021-06-10 20:43:57 +08:00
|
|
|
// this->m_ii = InotifyIndex::getInstance("/home");
|
|
|
|
// if(!this->m_ii->isRunning()) {
|
|
|
|
// this->m_ii->start();
|
|
|
|
// }
|
|
|
|
if(!this->m_iw->isRunning()) {
|
|
|
|
this->m_iw->start();
|
2021-04-20 16:24:07 +08:00
|
|
|
}
|
2021-04-26 15:06:47 +08:00
|
|
|
qDebug() << "Search method has been set to INDEXSEARCH";
|
2021-04-20 16:24:07 +08:00
|
|
|
}
|
2021-06-10 20:43:57 +08:00
|
|
|
if(FileUtils::SearchMethod::DIRECTSEARCH == sm) {
|
|
|
|
m_iw->stopWatch();
|
|
|
|
}
|
2021-04-20 16:24:07 +08:00
|
|
|
qWarning() << "searchMethod end: " << static_cast<int>(FileUtils::searchMethod);
|
|
|
|
}
|