Skip to content

fix: [378335] sync capabilities display filter with device manager - #226

Closed
tianming-1996 wants to merge 1 commit into
linuxdeepin:release/1071from
tianming-1996:release/1071
Closed

tianming-1996 wants to merge 1 commit into
linuxdeepin:release/1071from
tianming-1996:release/1071

Conversation

@tianming-1996

@tianming-1996 tianming-1996 commented Sep 28, 2026 •

Copy link
Copy Markdown

Root Cause Analysis

The disk manager (deepin-diskmanager, release/1071) and device manager (deepin-devicemanager, develop/eagle) display inconsistent "Capabilities" values for the same UFS disk. Both read the same lshw -C disk output (which contains partitioned partitioned:dos), but the device manager introduced cleanCapabilitiesForDisplay() in commit a28ba444a107 (2026-06-26) to remove the redundant bare partitioned token when a partitioned:<scheme> token is present, showing partitioned:dos. The disk manager displays the raw value partitioned partitioned:dos without any filtering (diskinfodisplaydialog.cpp:61).

Fix

Add a cleanCapabilitiesForDisplay() static helper function to diskinfodisplaydialog.cpp that mirrors the device manager's verified logic: when capabilities contain a partitioned:<scheme> token, skip the bare partitioned token. Apply this filter at the display layer where m_capabilities is rendered, so both applications consistently show partitioned:dos.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The new function is standalone with no side effects; no existing function logic is modified. The only call site is the capabilities display line in initUI().
  • Blame history shows the target file's last change was an unrelated dark-mode fix (PMS 247809, 2024-03-21); no conflict with this change.

Business Impact Scope

Affects the "Capabilities" field display in the disk info dialog (DiskInfoDisplayDialog). When a disk's capabilities include both bare partitioned and partitioned:<scheme> (e.g., UFS disks), the redundant bare token is now hidden. Disks without partitioned:<scheme> tokens are unaffected. No impact on data read/write, partition operations, or any other disk management functionality.

Verification Suggestion

Verify that the disk info dialog for a UFS disk now shows partitioned:dos (matching device manager) instead of partitioned partitioned:dos. Also confirm that disks without partition table schemes still display capabilities normally.


根因分析

磁盘管理器(release/1071)与设备管理器(develop/eagle)对同一 UFS 磁盘的"功能"字段显示不一致。两者均读取同一 lshw -C disk 输出(含 partitioned partitioned:dos),但设备管理器在提交 a28ba444a107(2026-06-26)中引入 cleanCapabilitiesForDisplay(),在存在 partitioned:<scheme> token 时移除冗余裸 partitioned,显示 partitioned:dos;磁盘管理器 diskinfodisplaydialog.cpp:61 直接显示原始值 partitioned partitioned:dos,无过滤。

修复方案

在 diskinfodisplaydialog.cpp 中新增 cleanCapabilitiesForDisplay() 静态辅助函数,同步设备管理器已验证的过滤逻辑:当 capabilities 含 partitioned:<scheme> token 时跳过裸 partitioned。在显示层 m_capabilities 渲染处应用此过滤,使两个应用统一显示 partitioned:dos。

改动安全评估

代码安全评估

  • 风险等级: 低
  • 新增函数为独立纯函数,无副作用,不修改任何已有函数逻辑。唯一调用点为 initUI() 中 capabilities 显示行。
  • Blame 历史显示目标文件最近改动为无关的暗色模式修复(PMS 247809,2024-03-21),与本次修复无冲突。

业务影响范围

影响磁盘信息对话框(DiskInfoDisplayDialog)中"功能"字段的显示。当磁盘 capabilities 同时包含裸 partitioned 和 partitioned:<scheme>(如 UFS 磁盘)时,冗余的裸 token 不再显示。不含 partitioned:<scheme> token 的磁盘不受影响。不影响数据读写、分区操作或其他磁盘管理功能。

验证建议

验证 UFS 磁盘信息对话框中"功能"字段显示为 partitioned:dos(与设备管理器一致),而非 partitioned partitioned:dos。同时确认无分区表方案的磁盘仍正常显示 capabilities。

Summary by Sourcery

Bug Fixes:

  • Align disk information capability displays with device manager by hiding redundant bare partitioned tokens when a partition scheme is present.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tianming-1996

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

@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议。
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai

sourcery-ai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

The disk information dialog now mirrors device manager capability-display filtering, removing redundant partitioned when a partition scheme such as partitioned:dos is present while leaving other capability displays unchanged.

Sequence diagram for filtered disk capabilities display

sequenceDiagram
    participant DiskInfoDisplayDialog
    participant HardDiskInfo
    participant cleanCapabilitiesForDisplay
    participant User

    DiskInfoDisplayDialog->>HardDiskInfo: m_capabilities
    DiskInfoDisplayDialog->>cleanCapabilitiesForDisplay: cleanCapabilitiesForDisplay(caps)
    alt caps contains partitioned:<scheme>
        cleanCapabilitiesForDisplay-->>DiskInfoDisplayDialog: capabilities without bare partitioned
    else no partitioned:<scheme>
        cleanCapabilitiesForDisplay-->>DiskInfoDisplayDialog: original capabilities
    end
    DiskInfoDisplayDialog-->>User: render Capabilities
Loading

File-Level Changes

Change Details Files
Normalize capability strings before rendering them in the disk information dialog.
  • Added a helper that detects partition scheme tokens and removes redundant bare partitioned tokens.
  • Applied the helper to the capabilities value displayed by initUI().
  • Preserved original output when no partitioned:<scheme> token is present.
application/widgets/diskinfodisplaydialog.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 97 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 97 分,大于 70 分通过阈值,代码质量符合要求。新增 cleanCapabilitiesForDisplay() 函数逻辑清晰,与设备管理器保持一致,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰。函数正确处理了空字符串、无 partition scheme、有 partition scheme 三种场景。Qt::SkipEmptyParts 确保分割后无空 token。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. application/widgets/diskinfodisplaydialog.cpp:23 - 新增函数 cleanCapabilitiesForDisplay 缺少函数注释,未说明函数用途和参数含义

建议: 建议为 cleanCapabilitiesForDisplay() 添加函数注释,说明功能(过滤冗余裸 partitioned token)、参数(caps - capabilities 字符串)和返回值(过滤后的字符串)。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. application/widgets/diskinfodisplaydialog.cpp:31 - 函数对 tokens 列表遍历两次(第一次检查 scheme,第二次过滤),可合并为单次遍历提升效率

建议: 性能良好,资源使用合理。对于典型 capabilities 字符串(短文本),双次遍历影响可忽略。如需优化可合并为单次遍历:先收集结果再决定是否返回原始值。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无安全风险。函数为纯字符串处理,无用户输入直接参与危险操作,无注入风险,无硬编码密钥,Qt 字符串处理内存安全。


💡 改进建议代码示例

// 建议添加函数注释,使用 range-based for 替代 foreach 宏
/**
 * @brief 清理 capabilities 显示字符串
 *        当存在 partitioned:<scheme> token 时,移除冗余的裸 partitioned token
 * @param caps 原始 capabilities 字符串
 * @return 清理后的 capabilities 字符串
 */
QString cleanCapabilitiesForDisplay(const QString &caps)
{
    if (caps.isEmpty())
        return caps;

    QStringList tokens = caps.split(" ", Qt::SkipEmptyParts);
    bool hasPartitionedScheme = false;
    for (const QString &token : tokens) {
        if (token.startsWith("partitioned:")) {
            hasPartitionedScheme = true;
            break;
        }
    }

    if (!hasPartitionedScheme)
        return caps;

    QStringList result;
    for (const QString &token : tokens) {
        if (token != "partitioned")
            result.append(token);
    }
    return result.join(" ");
}

本报告由 AI 代码审查工具自动生成

@tianming-1996

Copy link
Copy Markdown
Author

回退关闭:设备管理器(deepin-devicemanager)已通过 PR #784 回退 capabilities 清洗逻辑,恢复显示 lshw 原值(partitioned partitioned:dos)。因此磁盘管理器无需再同步该清洗逻辑,本 PR 关闭,磁盘管理器保持显示原始值 partitioned partitioned:dos,与设备管理器保持一致。

Revert rationale: device manager PR #784 reverts cleanCapabilitiesForDisplay(), restoring raw lshw capabilities. This PR (disk manager sync) is no longer needed.

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