Mark the whole drive as bad if one attribute is

This commit is contained in:
Spiros
2024-06-02 13:29:03 +03:00
parent 6886d70a5d
commit 64abe898a4

View File

@@ -76,6 +76,7 @@ void MainWindow::scanDevices()
QString temperature = "N/A"; QString temperature = "N/A";
bool healthPassed = localObj["smart_status"].toObject()["passed"].toBool(); bool healthPassed = localObj["smart_status"].toObject()["passed"].toBool();
bool caution = false; bool caution = false;
bool bad = false;
QString health; QString health;
QColor healthColor; QColor healthColor;
@@ -94,9 +95,11 @@ void MainWindow::scanDevices()
if (!isNvme) { if (!isNvme) {
for (const QJsonValue &attr : attributes) { for (const QJsonValue &attr : attributes) {
QJsonObject attrObj = attr.toObject(); QJsonObject attrObj = attr.toObject();
if (!isNvme && (attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && (attrObj["raw"].toObject()["value"].toInt() != 0)) { if ((attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && attrObj["raw"].toObject()["value"].toInt() != 0) {
caution = true; caution = true;
break; }
if ((attrObj["thresh"].toInt() != 0) && (attrObj["value"].toInt() < attrObj["thresh"].toInt())) {
bad = true;
} }
} }
} else { } else {
@@ -104,10 +107,10 @@ void MainWindow::scanDevices()
nvmeSmartOrdered = parser.parse(allOutput); nvmeSmartOrdered = parser.parse(allOutput);
} }
if (healthPassed && !caution) { if (healthPassed && !caution && !bad) {
health = "Good"; health = "Good";
healthColor = Qt::green; healthColor = Qt::green;
} else if (healthPassed && caution) { } else if (healthPassed && caution && !bad) {
health = "Caution"; health = "Caution";
healthColor = Qt::yellow; healthColor = Qt::yellow;
} else { } else {