fix(storage): show real partition table type in disk info - #224
tianming-1996 wants to merge 1 commit into
Conversation
Reviewer's GuideThe PR fixes inaccurate disk capability display by obtaining the partition-table type from lsblk, using it to correct lshw-derived partitioning tokens, and removing redundant bare Sequence diagram for normalized disk capability displaysequenceDiagram
participant PartedCore
participant DeviceStorage
participant Lsblk
participant Lshw
PartedCore->>DeviceStorage: getDiskInfoFromLsblk(devicepath)
DeviceStorage->>Lshw: read disk capabilities
Lshw-->>DeviceStorage: capabilities
PartedCore->>DeviceStorage: getDiskInfoPartTableType(devicepath)
DeviceStorage->>Lsblk: lsblk -d -o name,pttype devicepath
Lsblk-->>DeviceStorage: pttype
PartedCore->>DeviceStorage: cleanCapabilitiesForDisplay(capabilities, partTableType)
DeviceStorage-->>PartedCore: normalized capabilities
Flow diagram for partition capability normalizationflowchart TD
A[Disk capabilities from lshw] --> B[Read partition table type from lsblk pttype]
B --> C{pttype available}
C -->|yes| D[Replace partitioned scheme with pttype]
C -->|no| E[Preserve existing capabilities]
D --> F[Remove redundant bare partitioned token]
E --> G[Return display capabilities]
F --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[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 |
15af609 to
1f26e38
Compare
Read the partition table type from lsblk pttype and use it to normalize the capabilities string, so a GPT disk no longer shows "partitioned:dos" (which comes from lshw misreading the protective MBR) and the redundant bare "partitioned" token is dropped. Also add the missing LICENSES/GPL-3.0-or-later.txt, which the translation scripts reference, so the REUSE license check passes on release/1071. 从 lsblk pttype 读取分区表类型并用于修正 capabilities 显示,避免 GPT 盘因 lshw 误读保护性 MBR 而显示 partitioned:dos,同时去掉冗余的裸 partitioned。 补齐 release/1071 缺失的 LICENSES/GPL-3.0-or-later.txt(翻译脚本引用), 使 REUSE license 检查通过。 Log: 修复磁盘信息中分区表类型显示错误的问题 Influence: 磁盘信息的"功能"中分区表类型显示准确(如 GPT 盘显示 partitioned:gpt),不改变其它信息。
1f26e38 to
7c0af80
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 将 QString::SkipEmptyParts 替换为 Qt::SkipEmptyParts 以消除废弃警告,保持与 Qt 5.15+ 的兼容性 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 考虑将 hasPartitionedScheme 的检查与结果构建合并为单次遍历,或使用更简洁的条件表达式提升可读性 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议设置合理的超时时间,如 proc.waitForFinished(5000),并在超时后进行错误处理 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 建议使用 QProcess::start(program, args) 分离形式:proc.start("lsblk", QStringList() << "-d" << "-o" << "name,pttype" << devicePath),避免参数拼接 💡 改进建议代码示例// 修复建议1: 使用 Qt::SkipEmptyParts 替换废弃的 QString::SkipEmptyParts
QStringList tokens = caps.split(" ", Qt::SkipEmptyParts);
// 修复建议2: 使用分离参数形式调用 QProcess,并设置超时
QString DeviceStorage::getDiskInfoPartTableType(const QString &devicePath)
{
QProcess proc;
proc.start("lsblk", QStringList() << "-d" << "-o" << "name,pttype" << devicePath);
if (!proc.waitForStarted(3000)) {
return QString();
}
if (!proc.waitForFinished(5000)) {
proc.kill();
proc.waitForFinished(1000);
return QString();
}
QMap<QString, QString> mapInfo;
loadLsblkInfo(proc.readAllStandardOutput(), mapInfo);
if (mapInfo.size() == 1) {
return mapInfo.value(mapInfo.firstKey());
}
return QString();
}本报告由 AI 代码审查工具自动生成 |
Read the partition table type from lsblk pttype and use it to normalize the capabilities string, so a GPT disk no longer shows "partitioned:dos" (which comes from lshw misreading the protective MBR) and the redundant bare "partitioned" token is dropped.
从 lsblk pttype 读取分区表类型并用于修正 capabilities 显示,避免 GPT 盘因 lshw 误读保护性 MBR 而显示 partitioned:dos,同时去掉冗余的裸 partitioned。
Log: 修复磁盘信息中分区表类型显示错误的问题
Influence: 磁盘信息的"功能"中分区表类型显示准确(如 GPT 盘显示 partitioned:gpt),不改变其它信息。
Summary by Sourcery
Display accurate disk partition table types in storage information.
Bug Fixes:
Tests:
Chores: