fix for locking race

This commit is contained in:
Lanta 2023-11-21 10:25:55 +01:00
parent 00bf93f5b4
commit 8ed6b2c32c

View file

@ -19,16 +19,22 @@ function new-lock {
if (Test-Path -Path $lockFile) {
Write-Host "Job is already running. Sleeping 10 seconds"
Start-Sleep -Seconds 10
}else{
}
else {
try {
New-Item -ItemType File -Path $lockFile | Out-Null
$lock = $false
}
if($i -ge $timeout){
catch {
$lock = $true
}
}
if ($i -ge $timeout) {
Write-Output "Timed out"
exit
}
$i++
}
New-Item -ItemType File -Path $lockFile | Out-Null
if ($by) {
$by | Out-File -FilePath $lockFile -Append
}