Retry Linux path conversion for errors

This commit is contained in:
Manuel Thalmann 2024-08-20 00:20:33 +02:00
parent dfaac9ff98
commit 8629ed08fa

View file

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