Fixed Issue 382.
1.1 --- a/Hardware/HDD/AbstractHarddrive.cs Sat Oct 27 11:40:28 2012 +0000
1.2 +++ b/Hardware/HDD/AbstractHarddrive.cs Sun Oct 28 11:34:53 2012 +0000
1.3 @@ -196,7 +196,7 @@
1.4 DriveAttributeValue[] values = smart.ReadSmartData(handle, index);
1.5
1.6 foreach (KeyValuePair<SmartAttribute, Sensor> keyValuePair in sensors) {
1.7 - SmartAttribute attribute = keyValuePair.Key;
1.8 + SmartAttribute attribute = keyValuePair.Key;
1.9 foreach (DriveAttributeValue value in values) {
1.10 if (value.Identifier == attribute.Identifier) {
1.11 Sensor sensor = keyValuePair.Value;
1.12 @@ -210,11 +210,20 @@
1.13 if (usageSensor != null) {
1.14 long totalSize = 0;
1.15 long totalFreeSpace = 0;
1.16 +
1.17 for (int i = 0; i < driveInfos.Length; i++) {
1.18 - totalSize += driveInfos[i].TotalSize;
1.19 - totalFreeSpace += driveInfos[i].TotalFreeSpace;
1.20 + if (!driveInfos[i].IsReady)
1.21 + continue;
1.22 + try {
1.23 + totalSize += driveInfos[i].TotalSize;
1.24 + totalFreeSpace += driveInfos[i].TotalFreeSpace;
1.25 + } catch (IOException) { } catch (UnauthorizedAccessException) { }
1.26 }
1.27 - usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
1.28 + if (totalSize > 0) {
1.29 + usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
1.30 + } else {
1.31 + usageSensor.Value = null;
1.32 + }
1.33 }
1.34 }
1.35