mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge pull request #552 from Icinga:fix/cache_file_encoding_read_write
Fix: Cache file encoding read/write Fixes file encoding for Icinga for Windows v1.10.0 to ensure the cache is always properly created with the correct encoding
This commit is contained in:
commit
eae4c38f33
4 changed files with 35 additions and 4 deletions
2
cache/framework_cache.psm1
vendored
2
cache/framework_cache.psm1
vendored
|
|
@ -1,4 +1,4 @@
|
|||
<#
|
||||
<#
|
||||
### Note ###
|
||||
|
||||
This file is shipping plain with Icinga for Windows for each version.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,28 @@ Upgrading Icinga PowerShell Framework is usually quite straightforward.
|
|||
|
||||
Specific version upgrades are described below. Please note that version updates are incremental.
|
||||
|
||||
## Upgrading to v1.10.0 (2022-08-30)
|
||||
|
||||
Icinga for Windows v1.10.0 made some changes regarding encoding, to ensure Icinga checks are always properly encoded to work with German umlauts. Because of this change, the update from a previous Icinga for Windows version to v1.10.0 requires some additional steps. To properly upgrade your environment, please use the following code and add the `icinga-powershell-framework` update procedure in-between:
|
||||
|
||||
```powershell
|
||||
# Store our file locations in a variable
|
||||
$FrameworkRootPath = Get-IcingaFrameworkRootPath;
|
||||
$FrameworkCache = Get-IcingaFrameworkCodeCacheFile;
|
||||
|
||||
# Update your Icinga PowerShell Framework to the latest version (v1.10.0)
|
||||
Update-Icinga -Name 'framework' -Force -Confirm;
|
||||
|
||||
# Copy the newly created template for the cache file to location of the current cache
|
||||
Copy-Item -Path (Join-Path -Path $FrameworkRootPath -ChildPath '\templates\framework_cache.psm1.template') -Destination $FrameworkCache -Force | Out-Null;
|
||||
|
||||
# Import our module again to apply all changes and properly rebuild the cache
|
||||
Import-Module icinga-powershell-framework -Force;
|
||||
Import-Module icinga-powershell-framework -Global -Force;
|
||||
|
||||
# Add your own update procedure code
|
||||
```
|
||||
|
||||
## Upgrading to v1.8.0 (2022-02-08)
|
||||
|
||||
### Service Binary
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
* [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory`
|
||||
* [#524](https://github.com/Icinga/icinga-powershell-framework/issues/524) Fixes uninstallation process by improving the location handling of PowerShell instances with Icinga IMC or Shell
|
||||
* [#545](https://github.com/Icinga/icinga-powershell-framework/issues/545) Fixes `RemoteSource` being cleared within repository `.json` files during `Update-IcingaRepository` tasks
|
||||
* [#552](https://github.com/Icinga/icinga-powershell-framework/pull/552) Fixes file encoding for Icinga for Windows v1.10.0 to ensure the cache is always properly created with the correct encoding
|
||||
|
||||
### Enhancements
|
||||
|
||||
|
|
|
|||
|
|
@ -108,8 +108,16 @@ function Write-IcingaFrameworkCodeCache()
|
|||
# Load modules from directory
|
||||
Get-ChildItem -Path $directory -Recurse -Filter '*.psm1' |
|
||||
ForEach-Object {
|
||||
$CacheContent += (Get-Content -Path $_.FullName -Raw -Encoding 'UTF8');
|
||||
$CacheContent += "`r`n";
|
||||
[System.IO.FileStream]$FileStream = [System.IO.File]::Open(
|
||||
$_.FullName,
|
||||
[System.IO.FileMode]::Open,
|
||||
[System.IO.FileAccess]::Read,
|
||||
[System.IO.FileShare]::Read
|
||||
);
|
||||
$FileReader = New-Object 'System.IO.StreamReader'($FileStream), (New-Object System.Text.UTF8Encoding $TRUE);
|
||||
$CacheContent += $FileReader.ReadToEnd();
|
||||
$FileReader.Close();
|
||||
$FileReader.Dispose();
|
||||
}
|
||||
|
||||
$CacheContent += "Export-ModuleMember -Function @( '*' ) -Alias @( '*' ) -Variable @( '*' )";
|
||||
|
|
@ -122,7 +130,7 @@ function Write-IcingaFrameworkCodeCache()
|
|||
return;
|
||||
}
|
||||
|
||||
Set-Content -Path $CacheFile -Value $CacheContent -Encoding 'UTF8';
|
||||
[System.IO.File]::WriteAllLines($CacheFile, $CacheContent, (New-Object System.Text.UTF8Encoding $TRUE));
|
||||
|
||||
Remove-IcingaFrameworkDependencyFile;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue