diff --git a/libsearch/filesystemwatcher/file-system-watcher.cpp b/libsearch/filesystemwatcher/file-system-watcher.cpp index c47beea..d55dd47 100644 --- a/libsearch/filesystemwatcher/file-system-watcher.cpp +++ b/libsearch/filesystemwatcher/file-system-watcher.cpp @@ -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) { diff --git a/libsearch/filesystemwatcher/file-system-watcher.h b/libsearch/filesystemwatcher/file-system-watcher.h index 535be68..e63826a 100644 --- a/libsearch/filesystemwatcher/file-system-watcher.h +++ b/libsearch/filesystemwatcher/file-system-watcher.h @@ -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); diff --git a/libsearch/index/basic-indexer.cpp b/libsearch/index/basic-indexer.cpp index c6b69f3..87796c4 100644 --- a/libsearch/index/basic-indexer.cpp +++ b/libsearch/index/basic-indexer.cpp @@ -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 diff --git a/libsearch/index/batch-indexer.cpp b/libsearch/index/batch-indexer.cpp index 2d74bcc..6ced291 100644 --- a/libsearch/index/batch-indexer.cpp +++ b/libsearch/index/batch-indexer.cpp @@ -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(); diff --git a/libsearch/index/file-content-indexer.cpp b/libsearch/index/file-content-indexer.cpp index 81628ac..5dd23ee 100644 --- a/libsearch/index/file-content-indexer.cpp +++ b/libsearch/index/file-content-indexer.cpp @@ -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()) { diff --git a/libsearch/index/file-watcher.cpp b/libsearch/index/file-watcher.cpp index 789e215..758ce36 100644 --- a/libsearch/index/file-watcher.cpp +++ b/libsearch/index/file-watcher.cpp @@ -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); } diff --git a/libsearch/index/index-updater.cpp b/libsearch/index/index-updater.cpp index 27cf5f3..7c05611 100644 --- a/libsearch/index/index-updater.cpp +++ b/libsearch/index/index-updater.cpp @@ -31,9 +31,10 @@ IndexUpdater::IndexUpdater(const QVector& 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()) { diff --git a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp index 6c3e461..01a6755 100644 --- a/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp +++ b/ukui-search-service-dir-manager/dirwatcher/dir-watcher.cpp @@ -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); // } } }