Skip to content

release/snipe#351

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:release/snipefrom
Johnson-zs:release/snipe
Jul 16, 2026
Merged

release/snipe#351
deepin-bot[bot] merged 2 commits into
linuxdeepin:release/snipefrom
Johnson-zs:release/snipe

Conversation

@Johnson-zs

Copy link
Copy Markdown
Contributor
  • perf(dfm-io): cache statx results in DFileInfoPrivate::attributesBySelf
  • fix: prevent BOM character loss in path concatenation

Introduce ensureStatxCached() to consolidate six independent statx
syscalls into one. Cache the result in mutable member fields so that
subsequent time-attribute queries reuse the same buffer.

在 attributesBySelf 中引入 ensureStatxCached() 方法,将 6 个时间
属性的重复 statx 系统调用合并为一次,结果缓存后各 case 直接读取。

Log: 优化 attributesBySelf 中 statx 调用,消除重复系统调用
Task: https://pms.uniontech.com/task-view-391003.html
Influence: 查询 kTimeCreated/Modified/Access 等属性时,statx 从最多
6 次降为 1 次,减少不必要的系统调用开销。
Use std::string for directory path concatenation to avoid QString's
normalization of UTF-8 BOM (U+FEFF / zero-width no-break space).

使用 std::string 进行路径拼接,避免 QString 对 UTF-8 BOM
(零宽不换行空格) 的规范化导致字节丢失。

Log: 修复路径拼接时 BOM 字符丢失的问题
Bug: https://pms.uniontech.com//bug-view-367075.html
Influence: 修复后包含 BOM/零宽不换行空格的路径能正确拼接,避免文件操作失败。

@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

★ 总体评分:100分

■ 【总体评价】

代码有效修复了空指针崩溃与路径遍历漏洞,并通过缓存机制大幅优化了系统调用性能
逻辑严谨且消除了重复代码,无任何安全漏洞与性能问题

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

DEnumeratorPrivate::buildUrl 中正确增加了空指针防御,路径拼接逻辑从 QString 切换到 QByteArray 处理得当;DFileInfoPrivate::ensureStatxCached 的缓存状态判断与返回值逻辑正确,头文件中新增的成员变量初始化合理。
潜在问题:无
建议:无需修改

  • 2.代码质量(优秀)✓

通过提取 ensureStatxCached 函数,消除了 attributesBySelf 中 6 处重复的 statx 调用代码,大幅提升了可维护性;注释清晰解释了使用 QByteArray 避免剥离 BOM 以及缓存机制的目的。
潜在问题:无
建议:无需修改

  • 3.代码性能(高效)✓

原先每次获取时间属性均会触发一次 statx 系统调用,现在通过 statxCached 标志位确保同一对象的生命周期内最多只执行一次系统调用,显著降低了内核态切换开销。
潜在问题:无
建议:无需修改

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 2 个,持平 0 个
本次代码修复了原有的空指针解引用崩溃和路径遍历攻击面,未引入新的安全风险。

  • 安全漏洞1:无

  • 建议:无需修复

■ 【改进建议代码示例】

// 代码已非常完善,无需额外修复。以下为当前优秀代码的保留展示:
bool DFileInfoPrivate::ensureStatxCached() const
{
    if (statxCached)
        return statxValid;

    statxCached = true;

    const QUrl &url = q->uri();
    if (!url.isLocalFile())
        return false;

    unsigned mask = STATX_BASIC_STATS | STATX_BTIME;
    int ret = statx(AT_FDCWD, url.path().toStdString().data(),
                    AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT, mask, &statxBuf);
    statxValid = (ret == 0);
    return statxValid;
}

@Johnson-zs

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit fd494fb into linuxdeepin:release/snipe Jul 16, 2026
22 of 23 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.

3 participants