fix(ai-search):可以搜到黑名单中的文件.

This commit is contained in:
JunjieBai 2024-05-16 20:39:58 +08:00 committed by iaom
parent 77f0e52495
commit 3f9f78e82b
1 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,8 @@
#include "thumbnail-creator.h"
#include "file-indexer-config.h"
#include "data-collecter.h"
#include "file-utils.h"
#include "dir-watcher.h"
#include <unistd.h>
#include <QMessageBox>
#include <QJsonObject>
@ -293,6 +295,20 @@ void AiSearch::keywordSearch()
data_management_similarity_search(s_session, QJsonDocument(keyword).toJson().data(), &results);
for (const auto &aResult : QJsonDocument::fromJson(results).array()) {
if (aResult.isObject()) {
bool isBlocked(false);
QStringList blockList = DirWatcher::getDirWatcher()->getBlockDirsOfUser();
QString filePath = aResult.toObject().value("filepath").toString();
for (const auto& blockDir : blockList) {
if (FileUtils::isOrUnder(filePath, blockDir)) {
isBlocked = true;
break;
}
}
if (isBlocked) {
continue;
}
SearchPluginIface::ResultInfo ri;
if (createResultInfo(ri, aResult.toObject().value("filepath").toString())) {
AiSearchPlugin::mutex.lock();