Merge branch '0621-dev' into 'main'
Close inotify fd after closed file index service. See merge request kylin-desktop/ukui-search!40
This commit is contained in:
commit
1132ab11fa
|
@ -483,8 +483,10 @@ void FileUtils::getDocxTextContent(QString &path, QString &textcontent) {
|
|||
if(!file.open(QuaZip::mdUnzip))
|
||||
return;
|
||||
|
||||
if(!file.setCurrentFile("word/document.xml", QuaZip::csSensitive))
|
||||
if(!file.setCurrentFile("word/document.xml", QuaZip::csSensitive)) {
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
QuaZipFile fileR(&file);
|
||||
|
||||
fileR.open(QIODevice::ReadOnly); //读取方式打开
|
||||
|
@ -545,8 +547,10 @@ void FileUtils::getPptxTextContent(QString &path, QString &textcontent) {
|
|||
if(i.startsWith(prefix))
|
||||
fileList << i;
|
||||
}
|
||||
if(fileList.isEmpty())
|
||||
if(fileList.isEmpty()) {
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileList.size(); ++i){
|
||||
QString name = prefix + QString::number(i + 1) + ".xml";
|
||||
|
@ -650,8 +654,10 @@ void FileUtils::getXlsxTextContent(QString &path, QString &textcontent) {
|
|||
if(!file.open(QuaZip::mdUnzip))
|
||||
return;
|
||||
|
||||
if(!file.setCurrentFile("xl/sharedStrings.xml", QuaZip::csSensitive))
|
||||
if(!file.setCurrentFile("xl/sharedStrings.xml", QuaZip::csSensitive)) {
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
QuaZipFile fileR(&file);
|
||||
|
||||
fileR.open(QIODevice::ReadOnly);
|
||||
|
@ -706,8 +712,10 @@ void FileUtils::getXlsxTextContent(QString &path, QString &textcontent) {
|
|||
|
||||
void FileUtils::getPdfTextContent(QString &path, QString &textcontent) {
|
||||
Poppler::Document *doc = Poppler::Document::load(path);
|
||||
if(doc->isLocked())
|
||||
if(doc->isLocked()) {
|
||||
delete doc;
|
||||
return;
|
||||
}
|
||||
const QRectF qf;
|
||||
int pageNum = doc->numPages();
|
||||
for(int i = 0; i < pageNum; ++i) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "inotify-watch.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <malloc.h>
|
||||
#include <errno.h>
|
||||
using namespace Zeeker;
|
||||
static InotifyWatch* global_instance_InotifyWatch = nullptr;
|
||||
|
||||
|
@ -65,7 +66,7 @@ bool InotifyWatch::removeWatch(const QString &path, bool removeFromDatabase)
|
|||
// qDebug() << i.value();
|
||||
if(i.value().length() > path.length()) {
|
||||
if(i.value().startsWith(path)) {
|
||||
qDebug() << "remove path: " << i.value();
|
||||
// qDebug() << "remove path: " << i.value();
|
||||
inotify_rm_watch(m_inotifyFd, currentPath.key(path));
|
||||
currentPath.erase(i++);
|
||||
} else {
|
||||
|
@ -132,6 +133,8 @@ void InotifyWatch::run()
|
|||
if (m_inotifyFd > 0) {
|
||||
qDebug()<<"Inotify init success!";
|
||||
} else {
|
||||
printf("errno=%d\n",errno);
|
||||
printf("Mesg:%s\n",strerror(errno));
|
||||
Q_ASSERT_X(0, "InotifyWatch", "Failed to initialize inotify");
|
||||
}
|
||||
|
||||
|
@ -205,10 +208,12 @@ void InotifyWatch::run()
|
|||
assert(false);
|
||||
}
|
||||
}
|
||||
qDebug() << "Leave watch loop";
|
||||
if(FileUtils::SearchMethod::DIRECTSEARCH == FileUtils::searchMethod) {
|
||||
IndexStatusRecorder::getInstance()->setStatus(INOTIFY_NORMAL_EXIT, "3");
|
||||
removeWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation), false);
|
||||
}
|
||||
close(m_inotifyFd);
|
||||
// fcntl(m_inotifyFd, F_SETFD, FD_CLOEXEC);
|
||||
// m_notifier = new QSocketNotifier(m_inotifyFd, QSocketNotifier::Read);
|
||||
// connect(m_notifier, &QSocketNotifier::activated, this, &InotifyWatch::slotEvent, Qt::DirectConnection);
|
||||
|
|
Loading…
Reference in New Issue