Skip to content

Commit 84f03ea

Browse files
author
Andrew
authored
Merge branch 'main' into pscacheupdates
2 parents 58dbffe + 75c80d5 commit 84f03ea

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function Invoke-DscCacheRefresh {
262262
"Checking cache for stale entries" | Write-DscTrace
263263

264264
foreach ($cacheEntry in $dscResourceCacheEntries) {
265-
"Checking cache entry '$($cacheEntry.Type) $($cacheEntry.LastWriteTimes)'" | Write-DscTrace -Operation Trace
265+
#"Checking cache entry '$($cacheEntry.Type) $($cacheEntry.LastWriteTimes)'" | Write-DscTrace -Operation Trace
266266

267267
$cacheEntry.LastWriteTimes.PSObject.Properties | ForEach-Object {
268268

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ function Invoke-DscCacheRefresh {
7979
if ($dscResourceCacheEntries.Count -eq 0) {
8080
# if there is nothing in the cache file - refresh cache
8181
$refreshCache = $true
82+
"Filtered DscResourceCache cache is empty" | Write-DscTrace
83+
}
84+
else
85+
{
86+
"Checking cache for stale entries" | Write-DscTrace
87+
88+
foreach ($cacheEntry in $dscResourceCacheEntries) {
89+
#"Checking cache entry '$($cacheEntry.Type) $($cacheEntry.LastWriteTimes)'" | Write-DscTrace -Operation Trace
90+
91+
$cacheEntry.LastWriteTimes.PSObject.Properties | ForEach-Object {
92+
93+
if (-not ((Get-Item $_.Name).LastWriteTime.Equals([DateTime]$_.Value)))
94+
{
95+
"Detected stale cache entry '$($_.Name)'" | Write-DscTrace
96+
$refreshCache = $true
97+
break
98+
}
99+
}
82100

83101
"Filtered DscResourceCache cache is empty" | Write-DscTrace
84102
}

0 commit comments

Comments
 (0)