diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 0192119..6dc2a24 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -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) diff --git a/lib/core/cache/Set-IcingaCacheData.psm1 b/lib/core/cache/Set-IcingaCacheData.psm1 index cb0f0c8..419f5f0 100644 --- a/lib/core/cache/Set-IcingaCacheData.psm1 +++ b/lib/core/cache/Set-IcingaCacheData.psm1 @@ -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; }