From 64abe898a43ade5585c41c172d500cf2d0450d41 Mon Sep 17 00:00:00 2001 From: Spiros Date: Sun, 2 Jun 2024 13:29:03 +0300 Subject: [PATCH] Mark the whole drive as bad if one attribute is --- mainwindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index d03ee84..c2933a8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -76,6 +76,7 @@ void MainWindow::scanDevices() QString temperature = "N/A"; bool healthPassed = localObj["smart_status"].toObject()["passed"].toBool(); bool caution = false; + bool bad = false; QString health; QColor healthColor; @@ -94,9 +95,11 @@ void MainWindow::scanDevices() if (!isNvme) { for (const QJsonValue &attr : attributes) { 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; - break; + } + if ((attrObj["thresh"].toInt() != 0) && (attrObj["value"].toInt() < attrObj["thresh"].toInt())) { + bad = true; } } } else { @@ -104,10 +107,10 @@ void MainWindow::scanDevices() nvmeSmartOrdered = parser.parse(allOutput); } - if (healthPassed && !caution) { + if (healthPassed && !caution && !bad) { health = "Good"; healthColor = Qt::green; - } else if (healthPassed && caution) { + } else if (healthPassed && caution && !bad) { health = "Caution"; healthColor = Qt::yellow; } else {