# HG changeset patch # User moel.mich # Date 1351424093 0 # Node ID 8f16f03797f5bbcb4602e845d314b7a47334c5ed # Parent 76f859f4aea1cbedc92a7f47ad7d850e647c3aba Fixed Issue 382. diff -r 76f859f4aea1 -r 8f16f03797f5 Hardware/HDD/AbstractHarddrive.cs --- a/Hardware/HDD/AbstractHarddrive.cs Sat Oct 27 11:40:28 2012 +0000 +++ b/Hardware/HDD/AbstractHarddrive.cs Sun Oct 28 11:34:53 2012 +0000 @@ -196,7 +196,7 @@ DriveAttributeValue[] values = smart.ReadSmartData(handle, index); foreach (KeyValuePair keyValuePair in sensors) { - SmartAttribute attribute = keyValuePair.Key; + SmartAttribute attribute = keyValuePair.Key; foreach (DriveAttributeValue value in values) { if (value.Identifier == attribute.Identifier) { Sensor sensor = keyValuePair.Value; @@ -210,11 +210,20 @@ if (usageSensor != null) { long totalSize = 0; long totalFreeSpace = 0; + for (int i = 0; i < driveInfos.Length; i++) { - totalSize += driveInfos[i].TotalSize; - totalFreeSpace += driveInfos[i].TotalFreeSpace; + if (!driveInfos[i].IsReady) + continue; + try { + totalSize += driveInfos[i].TotalSize; + totalFreeSpace += driveInfos[i].TotalFreeSpace; + } catch (IOException) { } catch (UnauthorizedAccessException) { } } - usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize; + if (totalSize > 0) { + usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize; + } else { + usageSensor.Value = null; + } } }