From d1dfe2de52542025a0bb677d139146b654be273e Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:15:46 -0500 Subject: [PATCH] revert to user folder should be faster this way, and it wasn't actually causing the problems i thought it was causing pester tests pass for all kinds --- lib/Voicemeeter.psm1 | 4 ++++ lib/io.ps1 | 38 ++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/Voicemeeter.psm1 b/lib/Voicemeeter.psm1 index d132c4e..4d5519f 100644 --- a/lib/Voicemeeter.psm1 +++ b/lib/Voicemeeter.psm1 @@ -20,11 +20,15 @@ class Remote { [String]$vmpath [Hashtable]$kind [Object]$profiles + [String]$userpath + [String]$workingconfig Remote ([String]$kindId) { $this.vmpath = Setup_DLL $this.kind = GetKind($kindId) $this.profiles = Get_Profiles($this.kind.name) + $this.userpath = Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'Voicemeeter' + $this.workingconfig = Join-Path $this.userpath ('vm' + $this.kind.name + '_working.xml') } [string] ToString() { diff --git a/lib/io.ps1 b/lib/io.ps1 index 912f73e..23dfc4a 100644 --- a/lib/io.ps1 +++ b/lib/io.ps1 @@ -170,33 +170,31 @@ class IODevice : IRemote { hidden $_driver = $($this | Add-Member ScriptProperty 'driver' ` { if ([string]::IsNullOrEmpty($this.name)) { return '' } - - $type = $null - try { - $tmp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), "vmrtmp-$(New-Guid).xml") - $this.remote.Setter('Command.Save', $tmp) - $timeout = New-TimeSpan -Seconds 2 - $sw = [Diagnostics.Stopwatch]::StartNew() - $line = $null - do { - if (Test-Path $tmp) { + $path = $this.remote.workingconfig + $oldTime = if (Test-Path $path) { (Get-Item $path).LastWriteTime } else { [DateTime]::MinValue } + $this.remote.Setter('Command.Save', $path) + + $timeout = New-TimeSpan -Seconds 2 + $sw = [Diagnostics.Stopwatch]::StartNew() + $line = $null + do { + if (Test-Path $path) { + $newTime = (Get-Item $path).LastWriteTime + if ($newTime -gt $oldTime) { try { - $line = Get-Content $tmp | Select-String -Pattern "<$($this.kindOfDevice)Dev index='$($this.index + 1)'" -List + $line = Get-Content $path | Select-String -Pattern "<$($this.kindOfDevice)Dev index='$($this.index + 1)'" -List if ($line) { break } } catch {} } - Start-Sleep -Milliseconds 20 - } while ($sw.elapsed -lt $timeout) - if ($line -and $line.ToString() -match "type='(?\d+)'") { - $type = $matches['type'] - } - } - finally { - if (Test-Path $tmp) { - Remove-Item $tmp -Force } + Start-Sleep -Milliseconds 20 + } while ($sw.elapsed -lt $timeout) + + $type = $null + if ($line -and $line.ToString() -match "type='(?\d+)'") { + $type = $matches['type'] } if ($type -notin $this.drivers.Keys) { return 'unknown' }