fix for locking race #136

Merged
OpzekerIT merged 2 commits from dev into main 2023-11-21 09:27:42 +00:00
Showing only changes of commit b29c971d1a - Show all commits

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
}
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
}