Retry Linux path conversion for errors

This commit is contained in:
Manuel Thalmann 2024-08-20 00:20:33 +02:00
parent 2482dbb9d0
commit d4357d0925

View file

@ -30,6 +30,9 @@ $null = New-Module {
[string] $Path [string] $Path
) )
$completed = $false;
while (-not $completed) {
$job = Start-Job { $job = Start-Job {
$env:Value = Resolve-Path $Using:Path; $env:Value = Resolve-Path $Using:Path;
$env:WSLENV = "Value/p"; $env:WSLENV = "Value/p";
@ -39,12 +42,18 @@ $null = New-Module {
$result = Receive-Job -Wait $job; $result = Receive-Job -Wait $job;
if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) { if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) {
Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``"; Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``";
continue;
} }
if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) { if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) {
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``"; Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
continue;
}
$completed = $true;
} }
$result; $result;