Fixes file writer, which did not create files

This commit is contained in:
Lord Hepipud 2021-08-21 13:44:24 +02:00
parent 3375d78ba2
commit ce35afe19b

View file

@ -5,6 +5,19 @@ function Write-IcingaFileSecure()
$Value
);
if ([string]::IsNullOrEmpty($File)) {
return;
}
if ((Test-Path $File) -eq $FALSE) {
try {
New-Item -ItemType File -Path $File -ErrorAction Stop | Out-Null;
} catch {
Exit-IcingaThrowException -InputString $_.Exception -CustomMessage $File -StringPattern 'System.UnauthorizedAccessException' -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.CacheFolder;
Exit-IcingaThrowException -CustomMessage $_.Exception -ExceptionType 'Unhandled' -Force;
}
}
[int]$WaitTicks = 0;
[bool]$FileUpdated = $FALSE;