Skip to content

fix(dfm-search): exclude WeChat monthly archive dirs from search results - #371

Merged
deepin-bot[bot] merged 1 commit into
masterfrom
agent/bugfix/864985d4
Jul 27, 2026
Merged

fix(dfm-search): exclude WeChat monthly archive dirs from search results#371
deepin-bot[bot] merged 1 commit into
masterfrom
agent/bugfix/864985d4

Conversation

@Johnson-zs

Copy link
Copy Markdown
Contributor

根因分析

搜索"今天微信接受的文件"时,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:86exclude_patterns 遗漏月份目录模式
  • indexedstrategy.cpp:508-510 — 目录以 type=="dir" 被索引并随结果返回
  • semanticsearcher.cpp:291-296onEngineFinished 仅按 *_thumb.jpg 过滤,2026-07 不匹配从而通过

修复方案

loc_wechat_dataexclude_patterns 追加 [0-9][0-9][0-9][0-9]-[0-9][0-9],复用既有 QDir::match 过滤通道,无需改 C++ 代码。

已在 Qt 6.8 验证 QDir::match2026-07/2026-12 命中,abcd-ef2026-07.txt202607 均不命中,只精确排除月份目录、不误伤真实文件,且仅在微信搜索时生效。

改动安全评估

低风险:纯 JSON 配置追加,0 个代码调用者,复用已验证的 exclude_patternsQDir::match 过滤机制,作用域仅限 loc_wechat_data 规则命中场景。

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: 搜索"今天微信接受的文件"时不再返回微信自建的月份归档目录,仅返回实际接收的文件。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过新增正则模式优化了微信文件的搜索排除规则,逻辑正确且无安全风险
代码质量良好,符合规范,有效提升了搜索结果的准确性,扣5分因正则表达式可读性可进一步优化

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

修改位于 location_rules.json 文件中,为 exclude_patterns 数组新增了字符串 "[0-9][0-9][0-9][0-9]-[0-9][0-9]"。JSON 语法正确,数组元素以逗号分隔,格式无误。
潜在问题:无
建议:无

  • 2.代码质量(良好)✓

新增的正则模式能准确表达 YYYY-MM 的日期格式,意图清晰,符合配置文件的修改规范。
潜在问题:正则表达式略显冗长,可读性一般。
建议:如果搜索引擎支持,可考虑使用更简洁的 \d{4}-\d{2} 写法以提升可读性。

  • 3.代码性能(良好)✓

新增的排除规则在文件搜索时进行匹配,正则表达式简单且无回溯风险,不会对搜索性能产生负面影响。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
总体风险描述:本次修改仅为 JSON 配置文件增加静态字符串,无任何外部输入交互或代码执行路径,不存在安全攻击面。
建议:无需修复

■ 【改进建议代码示例】

{
    "exclude_patterns": ["*_thumb.jpg", "\\d{4}-\\d{2}"],
    "include_hidden": false,
    "im_received": true
}

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit f303185 into master Jul 27, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants