fix(dfm-search): exclude WeChat monthly archive dirs from search results - #371
Conversation
Add YYYY-MM glob pattern to loc_wechat_data exclude_patterns so that WeChat's auto-created monthly folders (e.g. 2026-07) are filtered out. 在 loc_wechat_data 规则的 exclude_patterns 中追加 YYYY-MM 月份目录通配, 过滤微信按月自动创建的归档目录,避免其混入搜索结果。 Log: 修复微信接收文件搜索结果包含月份目录的问题 PMS: BUG-371519 Influence: 搜索"今天微信接受的文件"时不再返回微信自建的月份归档目录,仅返回实际接收的文件。
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 |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 {
"exclude_patterns": ["*_thumb.jpg", "\\d{4}-\\d{2}"],
"include_hidden": false,
"im_received": true
} |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
根因分析
搜索"今天微信接受的文件"时,dfm-search 将范围收敛到微信接收目录
~/Documents/xwechat_files/<用户>/msg/{file,video},并叠加"今天"时间过滤。微信在这些目录下按月创建归档目录YYYY-MM(如2026-07),真实接收的文件存放在月份目录内部。根因:
loc_wechat_data规则的exclude_patterns仅含["*_thumb.jpg"],未覆盖月份目录名。这些月份目录被文件名索引以type=="dir"收录,被路径前缀查询(kAncestorPaths)+ "今天"时间过滤命中后,混入搜索结果。关键证据:
location_rules.json:86—exclude_patterns遗漏月份目录模式indexedstrategy.cpp:508-510— 目录以type=="dir"被索引并随结果返回semanticsearcher.cpp:291-296—onEngineFinished仅按*_thumb.jpg过滤,2026-07不匹配从而通过修复方案
在
loc_wechat_data的exclude_patterns追加[0-9][0-9][0-9][0-9]-[0-9][0-9],复用既有QDir::match过滤通道,无需改 C++ 代码。已在 Qt 6.8 验证
QDir::match:2026-07/2026-12命中,abcd-ef、2026-07.txt、202607均不命中,只精确排除月份目录、不误伤真实文件,且仅在微信搜索时生效。改动安全评估
低风险:纯 JSON 配置追加,0 个代码调用者,复用已验证的
exclude_patterns→QDir::match过滤机制,作用域仅限loc_wechat_data规则命中场景。