mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge pull request #352 from Icinga:fix/missing_file_creation_file_writer
Fix: File writer did not create non-existing files Fixes newly implemented file writer, by creating files which were not existing prior to writing into them.
This commit is contained in:
commit
1241c58909
1 changed files with 13 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue