diff --git a/service/diskoperation/DeviceStorage.cpp b/service/diskoperation/DeviceStorage.cpp index 17fcdcd..6fe1896 100755 --- a/service/diskoperation/DeviceStorage.cpp +++ b/service/diskoperation/DeviceStorage.cpp @@ -608,9 +608,9 @@ void DeviceStorage::getDiskInfoInterface(const QString &devicePath, QString &int return; } -void DeviceStorage::updateForHWDevice(const QString &devicePath) +void DeviceStorage::updateForHWDevice(const QString &/*devicePath*/) { - if (m_model != Utils::readContent("/proc/bootdevice/product_name").trimmed()) + if (Utils::readContent("/proc/bootdevice/product_name").trimmed().isEmpty()) return; // m_firmwareVersion @@ -622,6 +622,43 @@ void DeviceStorage::updateForHWDevice(const QString &devicePath) // hide mode and vendor m_model = ""; m_vendor = ""; + + // Normalize disk size + if (!m_size.isEmpty()) { + // Convert size string to bytes + qint64 bytes = 0; + QString sizeStr = m_size.toLower(); + + if (sizeStr.contains("bytes")) { + sizeStr = sizeStr.split("bytes").first().trimmed(); + bytes = sizeStr.toLongLong(); + } else { + // Handle GB/TB directly + double value = sizeStr.split(" ").first().toDouble(); + if (sizeStr.contains("gb")) { + bytes = value * 1000 * 1000 * 1000; + } else if (sizeStr.contains("tb")) { + bytes = value * 1000 * 1000 * 1000 * 1000; + } + } + + // Convert to standardized format + if (bytes > 0) { + // Convert to GB and round to standard sizes + int gb = qRound(bytes / (1000.0 * 1000 * 1000)); + if (gb < 200) { + return; + } else if (gb <= 300) { + m_size = "256 GB"; + } else if (gb <= 600) { + m_size = "512 GB"; + } else if (gb <= 1200){ + m_size = "1 TB"; + } else if (gb <= 2200) { + m_size = "2 TB"; + } + } + } } void DeviceStorage::getMapInfoFromSmartctl(QMap &mapInfo, const QString &info, const QString &ch)