fix(storage): widen disk size matching tolerance to ±2 GB - #722
Merged
Conversation
Adjust the nominal disk capacity boundaries in checkDiskSize() from ±1 GB to ±2 GB so that storage devices whose reported byte count deviates slightly more from the nominal value are still matched to the standard 256 GB / 512 GB / 1 TB / 2 TB labels. 将 checkDiskSize() 中磁盘容量匹配的上下限容差从 ±1 GB 调整为 ±2 GB,使上报字节数偏离标称值稍大的存储设备仍能匹配到标准的 256 GB / 512 GB / 1 TB / 2 TB 标签。 Log: 调整磁盘容量匹配上下限至±2GB PMS: 372871 Influence: checkDiskSize 的容量匹配逻辑,影响定制机型存储设备的容量显示规范化
Reviewer's guide (collapsed on small PRs)Reviewer's GuideWidens the acceptable byte ranges used by DeviceStorage::checkDiskSize() so that more disks are mapped to the standard 256 GB / 512 GB / 1 TB / 2 TB labels. Flow diagram for updated DeviceStorage::checkDiskSize() size matchingflowchart TD
A[m_SizeBytes] --> B{m_SizeBytes in 256GB range}
B -->|> 254*gbyte and < 258*gbyte| C[set m_Size = 256 GB]
B -->|else| D{m_SizeBytes in 512GB range}
D -->|> 510*gbyte and < 514*gbyte| E[set m_Size = 512 GB]
D -->|else| F{m_SizeBytes in 1TB range}
F -->|> 998*gbyte and < 1026*gbyte| G[set m_Size = 1 TB]
F -->|else| H{m_SizeBytes in 2TB range}
H -->|> 1998*gbyte and < 2050*gbyte| I[set m_Size = 2 TB]
H -->|else| J[m_Size unchanged]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 --- a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
+++ b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
@@ -577,13 +577,13 @@ void DeviceStorage::checkDiskSize()
quint64 gbyte = 1000000000;
// if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk
- if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) {
+ if (m_SizeBytes > 254*gbyte && m_SizeBytes < 258*gbyte) {
m_Size = "256 GB";
- } else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) {
+ } else if (m_SizeBytes > 510*gbyte && m_SizeBytes < 514*gbyte) {
m_Size = "512 GB";
- } else if (m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) {
+ } else if (m_SizeBytes > 998*gbyte && m_SizeBytes < 1026*gbyte) {
m_Size = "1 TB";
- } else if (m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) {
+ } else if (m_SizeBytes > 1998*gbyte && m_SizeBytes < 2050*gbyte) {
m_Size = "2 TB";
}
// } |
lzwind
approved these changes
Aug 6, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adjust the nominal disk capacity boundaries in checkDiskSize() from ±1 GB to ±2 GB so that storage devices whose reported byte count deviates slightly more from the nominal value are still matched to the standard 256 GB / 512 GB / 1 TB / 2 TB labels.
将 checkDiskSize() 中磁盘容量匹配的上下限容差从 ±1 GB 调整为
±2 GB,使上报字节数偏离标称值稍大的存储设备仍能匹配到标准的
256 GB / 512 GB / 1 TB / 2 TB 标签。
Log: 调整磁盘容量匹配上下限至±2GB
PMS: 372871
Influence: checkDiskSize 的容量匹配逻辑,影响定制机型存储设备的容量显示规范化
Summary by Sourcery
Bug Fixes: