增加unmount信号监听处理

This commit is contained in:
iaom 2022-12-23 11:11:06 +08:00
parent e3ef150d35
commit c6322feb77
8 changed files with 14 additions and 6 deletions

View File

@ -340,7 +340,7 @@ void FileSystemWatcher::eventProcess(int socket)
// This is present because a unmount event is sent by inotify after unmounting, by
// which time the watches have already been removed.
if (path != "/") {
Q_EMIT unmounted(path);
Q_EMIT unmounted(path, event->mask & IN_ISDIR);
}
}
if (event->mask & EventAttributeChange) {

View File

@ -151,7 +151,7 @@ Q_SIGNALS:
/**
* 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:
void eventProcess(int socket);

View File

@ -29,6 +29,9 @@ BasicIndexer::BasicIndexer(const QString& filePath): m_filePath(filePath)
bool BasicIndexer::index()
{
QFileInfo info = QFileInfo(m_filePath);
if(!info.exists()) {
return false;
}
//添加数据
m_document.setData(m_filePath);
//唯一term

View File

@ -264,7 +264,7 @@ void BatchIndexer::contentIndex()
++batchSize;
++finishNum;
} else {
qDebug() << "Extract fail===" << path;
// qDebug() << "Extract fail===" << path;
}
if(batchSize >= 30) {
contentDb.commit();
@ -295,7 +295,7 @@ void BatchIndexer::contentIndex()
++batchSize;
++ocrFinishNum;
} else {
qDebug() << "Extract fail===" << path;
// qDebug() << "Extract fail===" << path;
}
if(batchSize >= 30) {
contentDb.commit();

View File

@ -31,6 +31,9 @@ bool fileContentIndexer::index()
{
QString content;
QFileInfo info(m_filePath);
if(!info.exists()) {
return false;
}
QString suffix = info.suffix();
FileReader::getTextContent(m_filePath, content, suffix);
if(content.isEmpty()) {

View File

@ -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::deleted, 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);
}

View File

@ -31,9 +31,10 @@ IndexUpdater::IndexUpdater(const QVector<PendingFile>& files, QAtomicInt &stop)
m_stop(&stop)
{
}
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()) {
WritableDatabase basicDb(DataBaseType::Basic);
if(!basicDb.open()) {

View File

@ -601,7 +601,7 @@ void DirWatcher::handleDisk()
for (auto t = m_currentUDiskDeviceInfo.constBegin(); t != m_currentUDiskDeviceInfo.constEnd(); t++) {
for (QString udiskDevice: t.value()) {
// if (udiskDevice.startsWith("/data") || udiskDevice.startsWith("/home")) {
m_blackListOfIndex.append(udiskDevice);
// m_blackListOfIndex.append(udiskDevice);
// }
}
}