Merge pull request #829 from Icinga:fix/clearcache

Fix(lib/core): Allow Cache-Key deletion with NULL

Allows to delete Cache Entries. Usage `Set-IcingaCacheData -KeyName Key -Value $NULL`
This commit is contained in:
Lord Hepipud 2025-11-20 08:35:22 +01:00 committed by GitHub
commit c92c0eb410
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -28,6 +28,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#814](https://github.com/Icinga/icinga-powershell-framework/pull/814) Fixes random chars function to truly generate unpredictable character sequences and to replace `Get-Random` which is not entirely secure
* [#815](https://github.com/Icinga/icinga-powershell-framework/pull/815) Fixes a possible crash for `Test-IcingaAddTypeExist`, causing the Icinga for Windows installation to fail when third party components are checked which are malfunctioning
* [#829](https://github.com/Icinga/icinga-powershell-framework/pull/829) Fixes `Set-IcingaCacheData` to properly remove cache files in case `$null` is passed as value
## 1.13.3 (2025-05-08)

View file

@ -38,6 +38,16 @@ function Set-IcingaCacheData()
$CacheTmpFile = [string]::Format('{0}.tmp', $CacheFile);
$cacheData = @{ };
if ($null -eq $Value) {
if (Test-Path $CacheTmpFile) {
Remove-ItemSecure -Path $CacheTmpFile -Retries 5 -Force | Out-Null;
}
if (Test-Path $CacheFile) {
Remove-ItemSecure -Path $CacheFile -Retries 5 -Force | Out-Null;
}
return;
}
if ((Test-IcingaCacheDataTempFile -Space $Space -CacheStore $CacheStore -KeyName $KeyName)) {
Copy-IcingaCacheTempFile -CacheFile $CacheFile -CacheTmpFile $CacheTmpFile;
}