mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Merge pull request #804 from Icinga:fix/ifw_free_on_empty_config
Fix: Icinga for Windows freezing on empty config.json Fixes Icinga for Windows freezing during loading in case the `config.json` is empty
This commit is contained in:
commit
b127f5ced3
3 changed files with 34297 additions and 29 deletions
34310
cache/framework_cache.psm1
vendored
34310
cache/framework_cache.psm1
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
* [#785](https://github.com/Icinga/icinga-powershell-framework/issues/785) Fixes Icinga for Windows freezing during loading in case the `config.json` is empty
|
||||||
* [#787](https://github.com/Icinga/icinga-powershell-framework/pull/787) Fixes the return value in case the `Agent` component could not be installed from `$FALSE` to `null`
|
* [#787](https://github.com/Icinga/icinga-powershell-framework/pull/787) Fixes the return value in case the `Agent` component could not be installed from `$FALSE` to `null`
|
||||||
* [#796](https://github.com/Icinga/icinga-powershell-framework/issues/796) [#798](https://github.com/Icinga/icinga-powershell-framework/issues/798) Fixes an issue with the new check handling, which did not properly convert values from checks to the correct performance data values and base values in some cases
|
* [#796](https://github.com/Icinga/icinga-powershell-framework/issues/796) [#798](https://github.com/Icinga/icinga-powershell-framework/issues/798) Fixes an issue with the new check handling, which did not properly convert values from checks to the correct performance data values and base values in some cases
|
||||||
* [#797](https://github.com/Icinga/icinga-powershell-framework/issues/797) Fixes plugins throwing `UNKNOWN` in case `-TresholdInterval` is used for Metrics over Time, when checks are newly registered and checked, before the first MoT is executed and collected
|
* [#797](https://github.com/Icinga/icinga-powershell-framework/issues/797) Fixes plugins throwing `UNKNOWN` in case `-TresholdInterval` is used for Metrics over Time, when checks are newly registered and checked, before the first MoT is executed and collected
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,10 @@ function Get-FileEncoding()
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Bytes = Get-Content -Encoding Byte -ReadCount 4 -TotalCount 4 -Path $Path;
|
$FileStream = [System.IO.File]::OpenRead($Path);
|
||||||
|
$Bytes = New-Object Byte[] 4;
|
||||||
|
$FileStream.Read($Bytes, 0, 4) | Out-Null;
|
||||||
|
$FileStream.Close();
|
||||||
|
|
||||||
if ($Bytes[0] -eq 0xef -and $Bytes[1] -eq 0xbb -and $Bytes[2] -eq 0xbf) {
|
if ($Bytes[0] -eq 0xef -and $Bytes[1] -eq 0xbb -and $Bytes[2] -eq 0xbf) {
|
||||||
return 'UTF8-BOM';
|
return 'UTF8-BOM';
|
||||||
|
|
@ -52,8 +55,14 @@ function Get-FileEncoding()
|
||||||
return 'UTF32';
|
return 'UTF32';
|
||||||
} else {
|
} else {
|
||||||
# Check if the file is ASCII or UTF8 without BOM
|
# Check if the file is ASCII or UTF8 without BOM
|
||||||
$Content = Get-Content -Encoding String -Path $Path;
|
$Content = Get-Content -Encoding String -Path $Path -ErrorAction SilentlyContinue;
|
||||||
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($content);
|
|
||||||
|
# In case the file is empty, we assume it's UTF8
|
||||||
|
if ([string]::IsNullOrEmpty($Content)) {
|
||||||
|
return 'UTF8';
|
||||||
|
}
|
||||||
|
|
||||||
|
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($content);
|
||||||
|
|
||||||
# Check each byte to see if it's outside the ASCII range
|
# Check each byte to see if it's outside the ASCII range
|
||||||
foreach ($byte in $Bytes) {
|
foreach ($byte in $Bytes) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue