mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-30 22:05:08 +00:00
Fixed Issue 382.
This commit is contained in:
@@ -196,7 +196,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
DriveAttributeValue[] values = smart.ReadSmartData(handle, index);
|
DriveAttributeValue[] values = smart.ReadSmartData(handle, index);
|
||||||
|
|
||||||
foreach (KeyValuePair<SmartAttribute, Sensor> keyValuePair in sensors) {
|
foreach (KeyValuePair<SmartAttribute, Sensor> keyValuePair in sensors) {
|
||||||
SmartAttribute attribute = keyValuePair.Key;
|
SmartAttribute attribute = keyValuePair.Key;
|
||||||
foreach (DriveAttributeValue value in values) {
|
foreach (DriveAttributeValue value in values) {
|
||||||
if (value.Identifier == attribute.Identifier) {
|
if (value.Identifier == attribute.Identifier) {
|
||||||
Sensor sensor = keyValuePair.Value;
|
Sensor sensor = keyValuePair.Value;
|
||||||
@@ -210,11 +210,20 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
if (usageSensor != null) {
|
if (usageSensor != null) {
|
||||||
long totalSize = 0;
|
long totalSize = 0;
|
||||||
long totalFreeSpace = 0;
|
long totalFreeSpace = 0;
|
||||||
|
|
||||||
for (int i = 0; i < driveInfos.Length; i++) {
|
for (int i = 0; i < driveInfos.Length; i++) {
|
||||||
totalSize += driveInfos[i].TotalSize;
|
if (!driveInfos[i].IsReady)
|
||||||
totalFreeSpace += driveInfos[i].TotalFreeSpace;
|
continue;
|
||||||
|
try {
|
||||||
|
totalSize += driveInfos[i].TotalSize;
|
||||||
|
totalFreeSpace += driveInfos[i].TotalFreeSpace;
|
||||||
|
} catch (IOException) { } catch (UnauthorizedAccessException) { }
|
||||||
|
}
|
||||||
|
if (totalSize > 0) {
|
||||||
|
usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
|
||||||
|
} else {
|
||||||
|
usageSensor.Value = null;
|
||||||
}
|
}
|
||||||
usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user