@@ -73,50 +73,52 @@ function Invoke-DscCacheRefresh {
73
73
" Filtered DscResourceCache cache is empty" | Write-DscTrace
74
74
}
75
75
else {
76
- " Checking cache for stale entries " | Write-DscTrace
76
+ " Checking cache for stale PSModulePath " | Write-DscTrace
77
77
78
- foreach ( $cacheEntry in $dscResourceCacheEntries ) {
78
+ $m = $ env: PSModulePath -split [ IO.Path ]::PathSeparator | % { Get-ChildItem - Directory - Path $_ - Depth 1 - ea SilentlyContinue }
79
79
80
- $cacheEntry.LastWriteTimes.PSObject.Properties | ForEach-Object {
80
+ $hs_cache = [System.Collections.Generic.HashSet [string ]]($cache.PSModulePaths )
81
+ $hs_live = [System.Collections.Generic.HashSet [string ]]($m.FullName )
82
+ $hs_cache.SymmetricExceptWith ($hs_live )
83
+ $diff = $hs_cache
81
84
82
- if (Test-Path $_.Name ) {
83
- $file_LastWriteTime = (Get-Item $_.Name ).LastWriteTimeUtc
84
- # Truncate DateTime to seconds
85
- $file_LastWriteTime = $file_LastWriteTime.AddTicks ( - ($file_LastWriteTime.Ticks % [TimeSpan ]::TicksPerSecond));
85
+ " PSModulePath diff '$diff '" | Write-DscTrace
86
+ if ($diff.Count -gt 0 ) {
87
+ $refreshCache = $true
88
+ # Get all resources
89
+ $Module = $null
90
+ }
86
91
87
- $cache_LastWriteTime = [DateTime ]$_.Value
88
- # Truncate DateTime to seconds
89
- $cache_LastWriteTime = $cache_LastWriteTime.AddTicks ( - ($cache_LastWriteTime.Ticks % [TimeSpan ]::TicksPerSecond));
92
+ if (-not $refreshCache ) {
93
+ " Checking cache for stale entries" | Write-DscTrace
90
94
91
- if (-not ($file_LastWriteTime.Equals ($cache_LastWriteTime ))) {
92
- " Detected stale cache entry '$ ( $_.Name ) '" | Write-DscTrace
93
- $refreshCache = $true
94
- break
95
- }
96
- }
97
- else {
98
- " Detected non-existent cache entry '$ ( $_.Name ) '" | Write-DscTrace
99
- $refreshCache = $true
100
- break
101
- }
102
- }
95
+ foreach ($cacheEntry in $dscResourceCacheEntries ) {
103
96
104
- if ($refreshCache ) { break }
105
- }
97
+ $cacheEntry.LastWriteTimes.PSObject.Properties | ForEach-Object {
106
98
107
- if (-not $refreshCache ) {
108
- " Checking cache for stale PSModulePath" | Write-DscTrace
99
+ if (Test-Path $_.Name ) {
100
+ $file_LastWriteTime = (Get-Item $_.Name ).LastWriteTimeUtc
101
+ # Truncate DateTime to seconds
102
+ $file_LastWriteTime = $file_LastWriteTime.AddTicks ( - ($file_LastWriteTime.Ticks % [TimeSpan ]::TicksPerSecond));
109
103
110
- $m = $env: PSModulePath -split [IO.Path ]::PathSeparator | % { Get-ChildItem - Directory - Path $_ - Depth 1 - ea SilentlyContinue }
104
+ $cache_LastWriteTime = [DateTime ]$_.Value
105
+ # Truncate DateTime to seconds
106
+ $cache_LastWriteTime = $cache_LastWriteTime.AddTicks ( - ($cache_LastWriteTime.Ticks % [TimeSpan ]::TicksPerSecond));
111
107
112
- $hs_cache = [System.Collections.Generic.HashSet [string ]]($cache.PSModulePaths )
113
- $hs_live = [System.Collections.Generic.HashSet [string ]]($m.FullName )
114
- $hs_cache.SymmetricExceptWith ($hs_live )
115
- $diff = $hs_cache
108
+ if (-not ($file_LastWriteTime.Equals ($cache_LastWriteTime ))) {
109
+ " Detected stale cache entry '$ ( $_.Name ) '" | Write-DscTrace
110
+ $refreshCache = $true
111
+ break
112
+ }
113
+ }
114
+ else {
115
+ " Detected non-existent cache entry '$ ( $_.Name ) '" | Write-DscTrace
116
+ $refreshCache = $true
117
+ break
118
+ }
119
+ }
116
120
117
- " PSModulePath diff '$diff '" | Write-DscTrace
118
- if ($diff.Count -gt 0 ) {
119
- $refreshCache = $true
121
+ if ($refreshCache ) { break }
120
122
}
121
123
}
122
124
}
0 commit comments