forked from openkylin/ukui-search
增加unmount信号监听处理
This commit is contained in:
parent
e3ef150d35
commit
c6322feb77
|
@ -340,7 +340,7 @@ void FileSystemWatcher::eventProcess(int socket)
|
||||||
// This is present because a unmount event is sent by inotify after unmounting, by
|
// This is present because a unmount event is sent by inotify after unmounting, by
|
||||||
// which time the watches have already been removed.
|
// which time the watches have already been removed.
|
||||||
if (path != "/") {
|
if (path != "/") {
|
||||||
Q_EMIT unmounted(path);
|
Q_EMIT unmounted(path, event->mask & IN_ISDIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event->mask & EventAttributeChange) {
|
if (event->mask & EventAttributeChange) {
|
||||||
|
|
|
@ -151,7 +151,7 @@ Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* Emitted if a watched path has been unmounted (FileSystemWatcher::EventUnmount)
|
* Emitted if a watched path has been unmounted (FileSystemWatcher::EventUnmount)
|
||||||
*/
|
*/
|
||||||
void unmounted(const QString& path);
|
void unmounted(const QString& path, bool isDir);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void eventProcess(int socket);
|
void eventProcess(int socket);
|
||||||
|
|
|
@ -29,6 +29,9 @@ BasicIndexer::BasicIndexer(const QString& filePath): m_filePath(filePath)
|
||||||
bool BasicIndexer::index()
|
bool BasicIndexer::index()
|
||||||
{
|
{
|
||||||
QFileInfo info = QFileInfo(m_filePath);
|
QFileInfo info = QFileInfo(m_filePath);
|
||||||
|
if(!info.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//添加数据
|
//添加数据
|
||||||
m_document.setData(m_filePath);
|
m_document.setData(m_filePath);
|
||||||
//唯一term
|
//唯一term
|
||||||
|
|
|
@ -264,7 +264,7 @@ void BatchIndexer::contentIndex()
|
||||||
++batchSize;
|
++batchSize;
|
||||||
++finishNum;
|
++finishNum;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Extract fail===" << path;
|
// qDebug() << "Extract fail===" << path;
|
||||||
}
|
}
|
||||||
if(batchSize >= 30) {
|
if(batchSize >= 30) {
|
||||||
contentDb.commit();
|
contentDb.commit();
|
||||||
|
@ -295,7 +295,7 @@ void BatchIndexer::contentIndex()
|
||||||
++batchSize;
|
++batchSize;
|
||||||
++ocrFinishNum;
|
++ocrFinishNum;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Extract fail===" << path;
|
// qDebug() << "Extract fail===" << path;
|
||||||
}
|
}
|
||||||
if(batchSize >= 30) {
|
if(batchSize >= 30) {
|
||||||
contentDb.commit();
|
contentDb.commit();
|
||||||
|
|
|
@ -31,6 +31,9 @@ bool fileContentIndexer::index()
|
||||||
{
|
{
|
||||||
QString content;
|
QString content;
|
||||||
QFileInfo info(m_filePath);
|
QFileInfo info(m_filePath);
|
||||||
|
if(!info.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
QString suffix = info.suffix();
|
QString suffix = info.suffix();
|
||||||
FileReader::getTextContent(m_filePath, content, suffix);
|
FileReader::getTextContent(m_filePath, content, suffix);
|
||||||
if(content.isEmpty()) {
|
if(content.isEmpty()) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ FileWatcher::FileWatcher(QObject *parent) : QObject(parent), m_config(FileIndexe
|
||||||
connect(m_watcher, &FileSystemWatcher::modified, this, &FileWatcher::onFileModefied);
|
connect(m_watcher, &FileSystemWatcher::modified, this, &FileWatcher::onFileModefied);
|
||||||
connect(m_watcher, &FileSystemWatcher::deleted, this, &FileWatcher::onFileDeletedOrMoved);
|
connect(m_watcher, &FileSystemWatcher::deleted, this, &FileWatcher::onFileDeletedOrMoved);
|
||||||
connect(m_watcher, &FileSystemWatcher::moved, this, &FileWatcher::onFileDeletedOrMoved);
|
connect(m_watcher, &FileSystemWatcher::moved, this, &FileWatcher::onFileDeletedOrMoved);
|
||||||
|
connect(m_watcher, &FileSystemWatcher::unmounted, this, &FileWatcher::onFileDeletedOrMoved);
|
||||||
|
|
||||||
connect(m_pendingFileQUeue, &PendingFileQueue::filesUpdate, this, &FileWatcher::filesUpdate);
|
connect(m_pendingFileQUeue, &PendingFileQueue::filesUpdate, this, &FileWatcher::filesUpdate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,10 @@ IndexUpdater::IndexUpdater(const QVector<PendingFile>& files, QAtomicInt &stop)
|
||||||
m_stop(&stop)
|
m_stop(&stop)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexUpdater::UpdateIndex()
|
void IndexUpdater::UpdateIndex()
|
||||||
{
|
{
|
||||||
|
//fix me: How should I delete metadata of files below a folder
|
||||||
|
//that has been deleted(When a file watcher signal comes which only contains folder info)?
|
||||||
if(FileIndexerConfig::getInstance()->isFileIndexEnable()) {
|
if(FileIndexerConfig::getInstance()->isFileIndexEnable()) {
|
||||||
WritableDatabase basicDb(DataBaseType::Basic);
|
WritableDatabase basicDb(DataBaseType::Basic);
|
||||||
if(!basicDb.open()) {
|
if(!basicDb.open()) {
|
||||||
|
|
|
@ -601,7 +601,7 @@ void DirWatcher::handleDisk()
|
||||||
for (auto t = m_currentUDiskDeviceInfo.constBegin(); t != m_currentUDiskDeviceInfo.constEnd(); t++) {
|
for (auto t = m_currentUDiskDeviceInfo.constBegin(); t != m_currentUDiskDeviceInfo.constEnd(); t++) {
|
||||||
for (QString udiskDevice: t.value()) {
|
for (QString udiskDevice: t.value()) {
|
||||||
// if (udiskDevice.startsWith("/data") || udiskDevice.startsWith("/home")) {
|
// if (udiskDevice.startsWith("/data") || udiskDevice.startsWith("/home")) {
|
||||||
m_blackListOfIndex.append(udiskDevice);
|
// m_blackListOfIndex.append(udiskDevice);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue