From 3f9f78e82bdfaef6cbd154e65bc0e14ca4b4953b Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Thu, 16 May 2024 20:39:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai-search):=E5=8F=AF=E4=BB=A5=E6=90=9C?= =?UTF-8?q?=E5=88=B0=E9=BB=91=E5=90=8D=E5=8D=95=E4=B8=AD=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/aisearch/ai-search-plugin.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libsearch/aisearch/ai-search-plugin.cpp b/libsearch/aisearch/ai-search-plugin.cpp index 26889a1..a586b27 100644 --- a/libsearch/aisearch/ai-search-plugin.cpp +++ b/libsearch/aisearch/ai-search-plugin.cpp @@ -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 #include #include @@ -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();