fix: filter excluded paths in recent search strategy - #368
Conversation
There was a problem hiding this comment.
Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
68ab056 to
131e85c
Compare
1. 为 RecentSearchStrategy 新增 filterByExcludedPaths,按 searchExcludedPaths 过滤黑名单目录下的最近使用文件,与其它子引擎的排除语义对齐; 2. 采用路径边界匹配(excludedPath 或 excludedPath + "/")并经 QDir::cleanPath 标准化,避免 /home/uos/Downloads 误匹配 /home/uos/Downloads_backup; 3. 在 search() 过滤管道中尽早调用黑名单路径过滤; 4. 补充单元测试覆盖黑名单过滤、空黑名单、路径边界匹配及与关键词组合过滤的场景; ===================================== 1. added filterByExcludedPaths to RecentSearchStrategy to filter recently-used files under blacklisted directories via searchExcludedPaths, aligning with the exclusion semantics of other sub-engines; 2. used path-boundary matching (excludedPath or excludedPath + "/") with QDir::cleanPath normalization to avoid /home/uos/Downloads matching /home/uos/Downloads_backup; 3. invoked the excluded-paths filter early in the search() pipeline; 4. added unit tests covering blacklist filtering, empty blacklist, path-boundary matching, and combined keyword plus blacklist filtering; Log: 修复语义搜索走 Recent 子引擎时未过滤黑名单路径,导致黑名单目录下最近使用文件仍被搜出的问题 Bug: https://pms.uniontech.com/bug-view-371177.html
131e85c to
977c883
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 代码逻辑已非常完善,无需修改,保持原样即可。 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
根因分析
全局搜索将某目录加入黑名单后,使用智能语义搜索输入"今天打开过文件"仍能搜出黑名单目录下的文件。本 PR 修复 util-dfm(dfm-search 库)侧的缺陷。
dfm-search 的其它子引擎(FileName/Content/OCR)都尊重
searchExcludedPaths(),唯独RecentSearchStrategy全文无该引用、search()只做 keyword/extension/time 过滤。而"今天打开过文件"经action_rules.json命中action_recent→recentOnly=true→ 独占走 Recent 子引擎,黑名单目录下的最近使用文件不会被过滤。关键证据:
recentsearchstrategy.cpp全文无searchExcludedPaths引用;对比realtimestrategy.cpp:81/indexedstrategy.cpp:728均消费 excluded paths。修复方案
为
RecentSearchStrategy新增filterByExcludedPaths方法,按m_options.searchExcludedPaths()过滤黑名单目录下的最近使用项。采用路径边界匹配(excludedPath或excludedPath + "/"),并经QDir::cleanPath标准化,避免/home/uos/Downloads误匹配/home/uos/Downloads_backup。在search()过滤管道中尽早调用(Step 2,keyword 过滤之前)。补充 4 个单元测试:search_excludedPathsFilter_removesBlacklistedItems:黑名单目录下文件被过滤search_excludedPathsFilter_emptyKeepsAllItems:空黑名单保留全部search_excludedPathsCombinedWithKeyword_appliesBoth:黑名单+关键词组合过滤search_excludedPathsFilter_respectsPathBoundary:路径边界匹配,_backup/_archive不被误过滤注:本 bug 需与 dde-grand-search 侧修复(语义 worker 调用
setSearchExcludedPaths)同时合入,两层缺一不可。改动安全评估
低风险。新增 1 个 private 过滤方法 + 在
search()中调用,不改变任何公开 API 签名;路径边界匹配采用 Qt 标准QDir::cleanPath+startsWith(excludedPath + '/')惯用法。单元测试沿用现有stub-ext+TestableRecentStrategy测试范式。关联 PMS:https://pms.uniontech.com/bug-view-371177.html