fix: [378335] sync capabilities display filter with device manager - #226
tianming-1996 wants to merge 1 commit into
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
CLA Assistant Lite bot: You can retrigger this bot by commenting recheck in this Pull Request |
Reviewer's GuideThe disk information dialog now mirrors device manager capability-display filtering, removing redundant Sequence diagram for filtered disk capabilities displaysequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。函数正确处理了空字符串、无 partition scheme、有 partition scheme 三种场景。Qt::SkipEmptyParts 确保分割后无空 token。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议为 cleanCapabilitiesForDisplay() 添加函数注释,说明功能(过滤冗余裸 partitioned token)、参数(caps - capabilities 字符串)和返回值(过滤后的字符串)。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 性能良好,资源使用合理。对于典型 capabilities 字符串(短文本),双次遍历影响可忽略。如需优化可合并为单次遍历:先收集结果再决定是否返回原始值。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 无安全风险。函数为纯字符串处理,无用户输入直接参与危险操作,无注入风险,无硬编码密钥,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 代码审查工具自动生成 |
|
回退关闭:设备管理器(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. |
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 samelshw -C diskoutput (which containspartitioned partitioned:dos), but the device manager introducedcleanCapabilitiesForDisplay()in commita28ba444a107(2026-06-26) to remove the redundant barepartitionedtoken when apartitioned:<scheme>token is present, showingpartitioned:dos. The disk manager displays the raw valuepartitioned partitioned:doswithout any filtering (diskinfodisplaydialog.cpp:61).Fix
Add a
cleanCapabilitiesForDisplay()static helper function todiskinfodisplaydialog.cppthat mirrors the device manager's verified logic: when capabilities contain apartitioned:<scheme>token, skip the barepartitionedtoken. Apply this filter at the display layer wherem_capabilitiesis rendered, so both applications consistently showpartitioned:dos.Change Safety Assessment
Code Safety
initUI().Business Impact Scope
Affects the "Capabilities" field display in the disk info dialog (
DiskInfoDisplayDialog). When a disk's capabilities include both barepartitionedandpartitioned:<scheme>(e.g., UFS disks), the redundant bare token is now hidden. Disks withoutpartitioned:<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 ofpartitioned 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 显示行。业务影响范围
影响磁盘信息对话框(
DiskInfoDisplayDialog)中"功能"字段的显示。当磁盘 capabilities 同时包含裸partitioned和partitioned:<scheme>(如 UFS 磁盘)时,冗余的裸 token 不再显示。不含partitioned:<scheme>token 的磁盘不受影响。不影响数据读写、分区操作或其他磁盘管理功能。验证建议
验证 UFS 磁盘信息对话框中"功能"字段显示为
partitioned:dos(与设备管理器一致),而非partitioned partitioned:dos。同时确认无分区表方案的磁盘仍正常显示 capabilities。Summary by Sourcery
Bug Fixes:
partitionedtokens when a partition scheme is present.