mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-01 06:45:12 +00:00
Changed the HDD enumeration code to drop drives without smart support and without any non-zero-sized logical drives.
This commit is contained in:
@@ -71,7 +71,10 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
DriveInfo di = new DriveInfo(logicalDrive);
|
DriveInfo di = new DriveInfo(logicalDrive);
|
||||||
if (di.TotalSize > 0)
|
if (di.TotalSize > 0)
|
||||||
driveInfoList.Add(new DriveInfo(logicalDrive));
|
driveInfoList.Add(new DriveInfo(logicalDrive));
|
||||||
} catch (ArgumentException) { } catch (IOException) { }
|
} catch (ArgumentException) {
|
||||||
|
} catch (IOException) {
|
||||||
|
} catch (UnauthorizedAccessException) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
driveInfos = driveInfoList.ToArray();
|
driveInfos = driveInfoList.ToArray();
|
||||||
|
|
||||||
@@ -105,6 +108,23 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
string[] logicalDrives = smart.GetLogicalDrives(driveIndex);
|
string[] logicalDrives = smart.GetLogicalDrives(driveIndex);
|
||||||
if (logicalDrives == null || logicalDrives.Length == 0)
|
if (logicalDrives == null || logicalDrives.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
bool hasNonZeroSizeDrive = false;
|
||||||
|
foreach (string logicalDrive in logicalDrives) {
|
||||||
|
try {
|
||||||
|
DriveInfo di = new DriveInfo(logicalDrive);
|
||||||
|
if (di.TotalSize > 0) {
|
||||||
|
hasNonZeroSizeDrive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (ArgumentException) {
|
||||||
|
} catch (IOException) {
|
||||||
|
} catch (UnauthorizedAccessException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasNonZeroSizeDrive)
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
|
Reference in New Issue
Block a user