clean up IODevice.driver

'none' -> ''
early return if name is empty
This commit is contained in:
pblivingston 2026-03-03 19:54:39 -05:00
parent 8d267078ff
commit 6b2031de99

View File

@ -120,6 +120,8 @@ class IODevice : IRemote {
hidden $_driver = $($this | Add-Member ScriptProperty 'driver' `
{
if ([string]::IsNullOrEmpty($this.name)) { return '' }
$path = $this.remote.workingconfig
$oldTime = if (Test-Path $path) { (Get-Item $path).LastWriteTime } else { [DateTime]::MinValue }
@ -142,14 +144,11 @@ class IODevice : IRemote {
Start-Sleep -Milliseconds 20
} while ($sw.elapsed -lt $timeout)
if (-not $line) { return 'unknown' }
$type = $null
if ($line.ToString() -match "type='(?<type>\d+)'") {
if ($line -and $line.ToString() -match "type='(?<type>\d+)'") {
$type = $matches['type']
}
if ($null -eq $type) { return 'none' }
if ($type -notin $this.drivers.Keys) { return 'unknown' }
return $this.drivers[$type]
} `