2021-01-29 11:43:07 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* Authors: zhangzihao <zhangzihao@kylinos.cn>
|
|
|
|
|
* Modified by: zhangpengfei <zhangpengfei@kylinos.cn>
|
|
|
|
|
*
|
|
|
|
|
*/
|
2021-01-09 11:25:07 +08:00
|
|
|
|
//#include <QtConcurrent>
|
|
|
|
|
#include "first-index.h"
|
2022-03-04 15:15:07 +08:00
|
|
|
|
#include "dir-watcher.h"
|
2021-01-09 11:25:07 +08:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
|
using namespace UkuiSearch;
|
2022-03-15 13:53:38 +08:00
|
|
|
|
FirstIndex *FirstIndex::m_instance = nullptr;
|
|
|
|
|
std::once_flag g_firstIndexInstanceFlag;
|
|
|
|
|
FirstIndex::FirstIndex() : m_semaphore(INDEX_SEM, 1, QSystemSemaphore::AccessMode::Open)
|
|
|
|
|
{
|
2021-06-02 15:17:27 +08:00
|
|
|
|
m_pool.setMaxThreadCount(2);
|
|
|
|
|
m_pool.setExpiryTimeout(100);
|
2021-04-20 16:24:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 13:53:38 +08:00
|
|
|
|
FirstIndex *FirstIndex::getInstance()
|
|
|
|
|
{
|
|
|
|
|
std::call_once(g_firstIndexInstanceFlag, [] () {
|
|
|
|
|
m_instance = new FirstIndex;
|
|
|
|
|
});
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 15:06:47 +08:00
|
|
|
|
FirstIndex::~FirstIndex() {
|
2021-04-20 16:24:07 +08:00
|
|
|
|
qDebug() << "~FirstIndex";
|
2022-03-17 15:40:55 +08:00
|
|
|
|
if(this->m_indexData)
|
|
|
|
|
delete this->m_indexData;
|
|
|
|
|
this->m_indexData = nullptr;
|
|
|
|
|
if(this->m_contentIndexData)
|
|
|
|
|
delete this->m_contentIndexData;
|
|
|
|
|
this->m_contentIndexData = nullptr;
|
|
|
|
|
if(this->m_ocrIndexData)
|
|
|
|
|
delete this->m_ocrIndexData;
|
|
|
|
|
this->m_ocrIndexData = nullptr;
|
2021-04-20 16:24:07 +08:00
|
|
|
|
qDebug() << "~FirstIndex end";
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 11:16:26 +08:00
|
|
|
|
void FirstIndex::work(const QFileInfo& fileInfo) {
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// qDebug() << "there are some shit here"<<fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0");
|
2022-04-19 09:16:20 +08:00
|
|
|
|
this->m_indexData->enqueue(QVector<QString>() << fileInfo.fileName()
|
|
|
|
|
<< fileInfo.absoluteFilePath()
|
|
|
|
|
<< QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0")
|
|
|
|
|
<< fileInfo.lastModified().toString("yyyyMMddHHmmss"));
|
2022-01-21 16:53:19 +08:00
|
|
|
|
if (fileInfo.fileName().split(".", QString::SkipEmptyParts).length() < 2)
|
|
|
|
|
return;
|
|
|
|
|
if (true == targetFileTypeMap[fileInfo.fileName().split(".").last()]
|
|
|
|
|
and false == FileUtils::isEncrypedOrUnreadable(fileInfo.absoluteFilePath())) {
|
2021-06-07 15:37:06 +08:00
|
|
|
|
if (fileInfo.fileName().split(".").last() == "docx") {
|
2021-05-28 15:55:26 +08:00
|
|
|
|
QuaZip file(fileInfo.absoluteFilePath());
|
|
|
|
|
if(!file.open(QuaZip::mdUnzip))
|
|
|
|
|
return;
|
|
|
|
|
if(!file.setCurrentFile("word/document.xml", QuaZip::csSensitive))
|
|
|
|
|
return;
|
|
|
|
|
QuaZipFile fileR(&file);
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_contentIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileR.usize()));//docx解压缩后的xml文件为实际需要解析文件大小
|
2021-05-28 15:55:26 +08:00
|
|
|
|
file.close();
|
2021-06-07 15:37:06 +08:00
|
|
|
|
} else if (fileInfo.fileName().split(".").last() == "pptx") {
|
2021-05-28 15:55:26 +08:00
|
|
|
|
QuaZip file(fileInfo.absoluteFilePath());
|
|
|
|
|
if(!file.open(QuaZip::mdUnzip))
|
|
|
|
|
return;
|
|
|
|
|
QString prefix("ppt/slides/slide");
|
|
|
|
|
qint64 fileSize(0);
|
|
|
|
|
qint64 fileIndex(0);
|
|
|
|
|
for(QString i : file.getFileNameList()) {
|
|
|
|
|
if(i.startsWith(prefix)){
|
|
|
|
|
QString name = prefix + QString::number(fileIndex + 1) + ".xml";
|
|
|
|
|
fileIndex++;
|
|
|
|
|
if(!file.setCurrentFile(name)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
QuaZipFile fileR(&file);
|
|
|
|
|
fileSize += fileR.usize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
file.close();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_contentIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileSize));//pptx解压缩后的xml文件为实际需要解析文件大小
|
2021-06-07 15:37:06 +08:00
|
|
|
|
} else if (fileInfo.fileName().split(".").last() == "xlsx") {
|
2021-05-28 15:55:26 +08:00
|
|
|
|
QuaZip file(fileInfo.absoluteFilePath());
|
|
|
|
|
if(!file.open(QuaZip::mdUnzip))
|
|
|
|
|
return;
|
|
|
|
|
if(!file.setCurrentFile("xl/sharedStrings.xml", QuaZip::csSensitive))
|
|
|
|
|
return;
|
|
|
|
|
QuaZipFile fileR(&file);
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_contentIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileR.usize()));//xlsx解压缩后的xml文件为实际解析文件大小
|
2021-05-28 15:55:26 +08:00
|
|
|
|
file.close();
|
2021-06-07 15:37:06 +08:00
|
|
|
|
} else {
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_contentIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileInfo.size()));
|
2021-05-28 15:55:26 +08:00
|
|
|
|
}
|
2022-04-13 13:46:30 +08:00
|
|
|
|
} else if (true == targetPhotographTypeMap[fileInfo.fileName().split(".").last()]) {
|
|
|
|
|
if (FileUtils::isOcrSupportSize(fileInfo.absoluteFilePath())) {
|
|
|
|
|
this->m_contentIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileInfo.size()));
|
|
|
|
|
//this->m_ocrIndexData->enqueue(qMakePair(fileInfo.absoluteFilePath(),fileInfo.size()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-20 16:24:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 11:16:26 +08:00
|
|
|
|
void FirstIndex::addIndexPath(const QString path, const QStringList blockList)
|
|
|
|
|
{
|
|
|
|
|
m_semaphore.acquire();
|
|
|
|
|
setPath(QStringList() << path);
|
|
|
|
|
setBlockPath(blockList);
|
|
|
|
|
this->wait();
|
|
|
|
|
this->start();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 15:06:47 +08:00
|
|
|
|
void FirstIndex::run() {
|
2021-04-20 16:24:07 +08:00
|
|
|
|
QTime t1 = QTime::currentTime();
|
2021-04-16 16:09:50 +08:00
|
|
|
|
// Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running.
|
2021-05-13 11:17:07 +08:00
|
|
|
|
QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString();
|
|
|
|
|
QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString();
|
2022-04-14 11:16:26 +08:00
|
|
|
|
// QString ocrIndexDatabaseStatus = IndexStatusRecorder::getInstance()->getStatus(OCR_DATABASE_STATE).toString();
|
2021-05-13 11:17:07 +08:00
|
|
|
|
QString inotifyIndexStatus = IndexStatusRecorder::getInstance()->getStatus(INOTIFY_NORMAL_EXIT).toString();
|
2021-01-09 11:25:07 +08:00
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
qInfo() << "indexDataBaseStatus: " << indexDataBaseStatus;
|
|
|
|
|
qInfo() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus;
|
2022-04-14 11:16:26 +08:00
|
|
|
|
// qInfo() << "ocrIndexDatabaseStatus: " << ocrIndexDatabaseStatus;
|
2022-03-17 15:40:55 +08:00
|
|
|
|
qInfo() << "inotifyIndexStatus: " << inotifyIndexStatus;
|
2021-01-09 11:25:07 +08:00
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
m_allDatadaseStatus = inotifyIndexStatus == "2" ? true : false;
|
|
|
|
|
m_indexDatabaseStatus = indexDataBaseStatus == "2" ? true : false;
|
|
|
|
|
m_contentIndexDatabaseStatus = contentIndexDataBaseStatus == "2" ? true : false;
|
2022-04-14 11:16:26 +08:00
|
|
|
|
// m_ocrIndexDatabaseStatus = ocrIndexDatabaseStatus == "2" ? true : false;
|
2022-03-17 15:40:55 +08:00
|
|
|
|
|
|
|
|
|
if(m_allDatadaseStatus && m_indexDatabaseStatus && m_contentIndexDatabaseStatus /*&& m_ocrIndexDatabaseStatus*/) {
|
2022-04-14 11:16:26 +08:00
|
|
|
|
if(m_isFirstIndex) {
|
|
|
|
|
m_isFirstIndex = false;
|
|
|
|
|
m_semaphore.release(1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-04-25 10:23:20 +08:00
|
|
|
|
setPath(DirWatcher::getDirWatcher()->currentIndexableDir());
|
2022-04-14 11:16:26 +08:00
|
|
|
|
setBlockPath(DirWatcher::getDirWatcher()->currentBlackListOfIndex());
|
2021-01-10 09:01:22 +08:00
|
|
|
|
}
|
2021-01-09 11:25:07 +08:00
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
|
2022-04-14 11:16:26 +08:00
|
|
|
|
IndexStatusRecorder::getInstance()->setStatus(INOTIFY_NORMAL_EXIT, "0");
|
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_indexData = new QQueue<QVector<QString>>();
|
|
|
|
|
this->m_contentIndexData = new QQueue<QPair<QString,qint64>>();
|
|
|
|
|
// this->m_ocrIndexData = new QQueue<QPair<QString,qint64>>();
|
2021-01-26 11:32:02 +08:00
|
|
|
|
|
2021-11-09 10:07:41 +08:00
|
|
|
|
++FileUtils::indexStatus;
|
2021-01-21 13:50:21 +08:00
|
|
|
|
pid_t pid;
|
|
|
|
|
pid = fork();
|
2021-04-26 15:06:47 +08:00
|
|
|
|
if(pid == 0) {
|
2021-01-23 09:52:44 +08:00
|
|
|
|
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
2021-04-26 15:06:47 +08:00
|
|
|
|
prctl(PR_SET_NAME, "first-index");
|
2022-03-17 15:40:55 +08:00
|
|
|
|
|
2021-01-21 13:50:21 +08:00
|
|
|
|
QSemaphore sem(5);
|
|
|
|
|
QMutex mutex1, mutex2, mutex3;
|
|
|
|
|
mutex1.lock();
|
|
|
|
|
mutex2.lock();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// mutex3.lock();
|
2022-03-04 15:15:07 +08:00
|
|
|
|
|
2022-04-25 10:23:20 +08:00
|
|
|
|
//FIXME:在子进程里使用和父进程同样的dbus接口会出问题。
|
|
|
|
|
// qInfo() << "index dir" << DirWatcher::getDirWatcher()->currentIndexableDir();
|
|
|
|
|
// qInfo() << "index block dir" << DirWatcher::getDirWatcher()->currentBlackListOfIndex();
|
|
|
|
|
qInfo() << "index dir" << m_pathList;
|
|
|
|
|
qInfo() << "index block dir" << m_blockList;
|
2022-03-15 13:53:38 +08:00
|
|
|
|
this->Traverse();
|
2022-03-04 15:15:07 +08:00
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
FileUtils::maxIndexCount = this->m_indexData->length();
|
|
|
|
|
qDebug() << "max_index_count:" << FileUtils::maxIndexCount;
|
2021-06-02 15:17:27 +08:00
|
|
|
|
QtConcurrent::run(&m_pool, [&]() {
|
2021-01-21 13:50:21 +08:00
|
|
|
|
sem.acquire(2);
|
2022-03-15 13:53:38 +08:00
|
|
|
|
mutex1.unlock();
|
2022-04-14 11:16:26 +08:00
|
|
|
|
if(m_isFirstIndex && m_allDatadaseStatus && m_indexDatabaseStatus) {
|
2022-03-17 15:40:55 +08:00
|
|
|
|
sem.release(2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "index start;" << m_indexData->size();
|
|
|
|
|
IndexGenerator::getInstance()->rebuildIndexDatabase();
|
2021-06-02 15:17:27 +08:00
|
|
|
|
QQueue<QVector<QString>>* tmp1 = new QQueue<QVector<QString>>();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
bool sucess = true;
|
|
|
|
|
while(!this->m_indexData->empty()) {
|
|
|
|
|
for(size_t i = 0; (i < 8192) && (!this->m_indexData->empty()); ++i) {
|
|
|
|
|
tmp1->enqueue(this->m_indexData->dequeue());
|
|
|
|
|
}
|
|
|
|
|
if(!IndexGenerator::getInstance()->creatAllIndex(tmp1)) {
|
|
|
|
|
sucess = false;
|
|
|
|
|
break;
|
2021-02-27 10:51:19 +08:00
|
|
|
|
}
|
2021-06-02 15:17:27 +08:00
|
|
|
|
tmp1->clear();
|
2021-02-27 10:51:19 +08:00
|
|
|
|
}
|
2021-06-02 15:17:27 +08:00
|
|
|
|
delete tmp1;
|
2021-01-21 13:50:21 +08:00
|
|
|
|
qDebug() << "index end;";
|
2022-03-17 15:40:55 +08:00
|
|
|
|
if(sucess) {
|
|
|
|
|
IndexStatusRecorder::getInstance()->setStatus(INDEX_DATABASE_STATE, "2");
|
|
|
|
|
}
|
2021-01-21 13:50:21 +08:00
|
|
|
|
sem.release(2);
|
|
|
|
|
});
|
2021-06-02 15:17:27 +08:00
|
|
|
|
QtConcurrent::run(&m_pool,[&]() {
|
2021-01-21 13:50:21 +08:00
|
|
|
|
sem.acquire(2);
|
2022-03-15 13:53:38 +08:00
|
|
|
|
mutex2.unlock();
|
2022-04-14 11:16:26 +08:00
|
|
|
|
if(m_isFirstIndex && m_allDatadaseStatus && m_contentIndexDatabaseStatus) {
|
2022-03-17 15:40:55 +08:00
|
|
|
|
sem.release(2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "content index start:" << m_contentIndexData->size();
|
|
|
|
|
IndexGenerator::getInstance()->rebuildContentIndexDatabase();
|
2021-06-02 15:17:27 +08:00
|
|
|
|
QQueue<QString>* tmp2 = new QQueue<QString>();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
bool sucess = true;
|
|
|
|
|
while(!this->m_contentIndexData->empty()) {
|
2021-05-22 09:18:35 +08:00
|
|
|
|
qint64 fileSize = 0;
|
|
|
|
|
//修改一次处理的数据量,从30个文件改为文件总大小为50M以下,50M为暂定值--jxx20210519
|
2022-03-17 15:40:55 +08:00
|
|
|
|
for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->m_contentIndexData->empty()); ++i) {
|
|
|
|
|
QPair<QString,qint64> tempPair = this->m_contentIndexData->dequeue();
|
2021-05-22 09:18:35 +08:00
|
|
|
|
fileSize += tempPair.second;
|
2021-06-07 15:37:06 +08:00
|
|
|
|
if (fileSize > 52428800 ) {
|
|
|
|
|
if (tmp2->size() == 0) {
|
|
|
|
|
tmp2->enqueue(tempPair.first);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-03-17 15:40:55 +08:00
|
|
|
|
this->m_contentIndexData->enqueue(tempPair);
|
2021-06-07 15:37:06 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-06-02 15:17:27 +08:00
|
|
|
|
tmp2->enqueue(tempPair.first);
|
2021-02-27 10:51:19 +08:00
|
|
|
|
}
|
2022-03-17 15:40:55 +08:00
|
|
|
|
if(!IndexGenerator::getInstance()->creatAllIndex(tmp2)) {
|
|
|
|
|
sucess = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-06-02 15:17:27 +08:00
|
|
|
|
tmp2->clear();
|
2021-02-27 10:51:19 +08:00
|
|
|
|
}
|
2021-06-02 15:17:27 +08:00
|
|
|
|
delete tmp2;
|
2021-01-21 13:50:21 +08:00
|
|
|
|
qDebug() << "content index end;";
|
2022-03-17 15:40:55 +08:00
|
|
|
|
if(sucess) {
|
|
|
|
|
IndexStatusRecorder::getInstance()->setStatus(CONTENT_INDEX_DATABASE_STATE, "2");
|
|
|
|
|
}
|
2021-01-21 13:50:21 +08:00
|
|
|
|
sem.release(2);
|
|
|
|
|
});
|
2022-04-13 13:46:30 +08:00
|
|
|
|
// OCR功能目前合到内容搜索分类中
|
2022-01-21 16:53:19 +08:00
|
|
|
|
// QtConcurrent::run(&m_pool,[&]() {
|
|
|
|
|
// sem.acquire(5);
|
2022-03-15 13:53:38 +08:00
|
|
|
|
// mutex3.unlock();
|
2022-01-21 16:53:19 +08:00
|
|
|
|
// QQueue<QString>* tmpOcr = new QQueue<QString>();
|
|
|
|
|
// qDebug() << "m_ocr_index:" << m_ocr_index->size();
|
2022-04-14 11:16:26 +08:00
|
|
|
|
// if(m_isFirstIndex && m_allDatadaseStatus && m_contentIndexDatabaseStatus) {
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// sem.release(2);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// IndexGenerator::getInstance()->rebuildOcrIndexDatabase();
|
|
|
|
|
// bool sucess = true;
|
2022-01-21 16:53:19 +08:00
|
|
|
|
// while(!this->m_ocr_index->empty()) {
|
|
|
|
|
// qint64 fileSize = 0;
|
|
|
|
|
// //一次处理的数据量文件总大小为50M以下,50M为暂定值
|
|
|
|
|
// for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->m_ocr_index->empty()); ++i) {
|
|
|
|
|
// QPair<QString,qint64> tempPair = this->m_ocr_index->dequeue();
|
|
|
|
|
// fileSize += tempPair.second;
|
|
|
|
|
// if (fileSize > 52428800) {
|
|
|
|
|
// if (tmpOcr->size() == 0) {
|
|
|
|
|
// tmpOcr->enqueue(tempPair.first);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// this->m_ocr_index->enqueue(tempPair);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// tmpOcr->enqueue(tempPair.first);
|
|
|
|
|
// }
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// if(!IndexGenerator::getInstance()->creatAllIndex(tmpOcr)) {
|
|
|
|
|
// sucess = false;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
2022-01-21 16:53:19 +08:00
|
|
|
|
// tmpOcr->clear();
|
|
|
|
|
// }
|
|
|
|
|
// delete tmpOcr;
|
|
|
|
|
// qDebug() << "OCR index end;";
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// if(sucess) {
|
|
|
|
|
// IndexStatusRecorder::getInstance()->setStatus(OCR_DATABASE_STATE, "2");
|
|
|
|
|
// }
|
2022-01-21 16:53:19 +08:00
|
|
|
|
// sem.release(5);
|
|
|
|
|
// });
|
2021-01-21 13:50:21 +08:00
|
|
|
|
mutex1.lock();
|
|
|
|
|
mutex2.lock();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// mutex3.lock();
|
2021-01-21 13:50:21 +08:00
|
|
|
|
sem.acquire(5);
|
2021-01-09 11:25:07 +08:00
|
|
|
|
mutex1.unlock();
|
|
|
|
|
mutex2.unlock();
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// mutex3.unlock();
|
2021-01-11 16:59:50 +08:00
|
|
|
|
|
2022-03-17 15:40:55 +08:00
|
|
|
|
if(this->m_indexData)
|
|
|
|
|
delete this->m_indexData;
|
|
|
|
|
this->m_indexData = nullptr;
|
|
|
|
|
if(this->m_contentIndexData)
|
|
|
|
|
delete this->m_contentIndexData;
|
|
|
|
|
this->m_contentIndexData = nullptr;
|
|
|
|
|
if(this->m_ocrIndexData)
|
|
|
|
|
delete this->m_ocrIndexData;
|
|
|
|
|
this->m_ocrIndexData = nullptr;
|
2021-02-06 15:13:05 +08:00
|
|
|
|
::_exit(0);
|
2021-04-26 15:06:47 +08:00
|
|
|
|
} else if(pid < 0) {
|
|
|
|
|
qWarning() << "First Index fork error!!";
|
|
|
|
|
} else {
|
|
|
|
|
waitpid(pid, NULL, 0);
|
2021-11-09 10:07:41 +08:00
|
|
|
|
--FileUtils::indexStatus;
|
2021-01-21 13:50:21 +08:00
|
|
|
|
}
|
2021-01-11 16:59:50 +08:00
|
|
|
|
|
2022-04-14 11:16:26 +08:00
|
|
|
|
m_isFirstIndex = false; //首次索引后置为false,后续start为添加索引目录时新建索引。
|
2021-05-13 11:17:07 +08:00
|
|
|
|
IndexStatusRecorder::getInstance()->setStatus(INOTIFY_NORMAL_EXIT, "2");
|
2022-04-14 11:16:26 +08:00
|
|
|
|
m_semaphore.release(1);
|
2022-03-17 15:40:55 +08:00
|
|
|
|
// int retval1 = write(fifo_fd, buffer, strlen(buffer));
|
|
|
|
|
// if(retval1 == -1) {
|
|
|
|
|
// qWarning("write error\n");
|
|
|
|
|
// }
|
|
|
|
|
// qDebug("write data ok!\n");
|
2021-02-27 10:51:19 +08:00
|
|
|
|
QTime t2 = QTime::currentTime();
|
|
|
|
|
qWarning() << t1;
|
|
|
|
|
qWarning() << t2;
|
2021-02-25 14:40:44 +08:00
|
|
|
|
|
2021-01-26 11:32:02 +08:00
|
|
|
|
return;
|
2021-01-11 16:59:50 +08:00
|
|
|
|
|
2021-01-09 11:25:07 +08:00
|
|
|
|
}
|