Skip to content

Commit c92c0eb

Browse files
authored
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`
2 parents 72be26f + 44700e4 commit c92c0eb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2828

2929
* [#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
3030
* [#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
31+
* [#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
3132

3233
## 1.13.3 (2025-05-08)
3334

lib/core/cache/Set-IcingaCacheData.psm1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ function Set-IcingaCacheData()
3838
$CacheTmpFile = [string]::Format('{0}.tmp', $CacheFile);
3939
$cacheData = @{ };
4040

41+
if ($null -eq $Value) {
42+
if (Test-Path $CacheTmpFile) {
43+
Remove-ItemSecure -Path $CacheTmpFile -Retries 5 -Force | Out-Null;
44+
}
45+
if (Test-Path $CacheFile) {
46+
Remove-ItemSecure -Path $CacheFile -Retries 5 -Force | Out-Null;
47+
}
48+
return;
49+
}
50+
4151
if ((Test-IcingaCacheDataTempFile -Space $Space -CacheStore $CacheStore -KeyName $KeyName)) {
4252
Copy-IcingaCacheTempFile -CacheFile $CacheFile -CacheTmpFile $CacheTmpFile;
4353
}

0 commit comments

Comments
 (0)