Merge pull request #136 from OpzekerIT/dev

fix for locking race
This commit is contained in:
Lanta 2023-11-21 10:27:42 +01:00 committed by GitHub
commit b82922272c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,16 +19,23 @@ 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 {
Write-Output "Unable to create lockfile , resuming lock loop"
$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
}