Skip to content

Commit ada2b4c

Browse files
committed
Fixes recursive loop on first loading of Framework
1 parent 2772c88 commit ada2b4c

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

cache/framework_cache.psm1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88
Manually enabling the feature is no longer required.
99
#>
1010

11+
# Ensure we only load this module once
12+
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
13+
return;
14+
}
15+
16+
if ($null -eq $Global:Icinga) {
17+
$Global:Icinga = @{ };
18+
}
19+
20+
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
21+
$Global:Icinga.Add('CacheBuilding', $TRUE);
22+
} else {
23+
$Global:Icinga.CacheBuilding = $TRUE;
24+
}
25+
1126
# Ensures that VS Code is not generating the cache file
1227
if ($null -ne $env:TERM_PROGRAM) {
1328
Write-IcingaFrameworkCodeCache -DeveloperMode;
@@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
2237
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
2338
Copy-IcingaFrameworkCacheTemplate;
2439
}
40+
41+
$Global:Icinga.CacheBuilding = $FALSE;

icinga-powershell-framework.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ function Write-IcingaFrameworkCodeCache()
132132

133133
[System.IO.File]::WriteAllLines($CacheFile, $CacheContent, (New-Object System.Text.UTF8Encoding $TRUE));
134134

135-
Remove-IcingaFrameworkDependencyFile;
135+
$DependencyFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework_dependencies.json';
136+
137+
if ((Test-Path $DependencyFile)) {
138+
Remove-Item -Path $DependencyFile -Force | Out-Null;
139+
}
136140

137141
if ($Global:Icinga.Protected.DeveloperMode) {
138142
Copy-IcingaFrameworkCacheTemplate;

lib/core/framework/New-IcingaEnvironmentVariable.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function New-IcingaEnvironmentVariable()
1515
$Global:Icinga = @{ };
1616
}
1717

18+
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
19+
$Global:Icinga.Add('CacheBuilding', $FALSE);
20+
}
21+
1822
# Session specific configuration for this shell
1923
if ($Global:Icinga.ContainsKey('Private') -eq $FALSE) {
2024
$Global:Icinga.Add('Private', @{ });

templates/framework_cache.psm1.template

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88
Manually enabling the feature is no longer required.
99
#>
1010

11+
# Ensure we only load this module once
12+
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
13+
return;
14+
}
15+
16+
if ($null -eq $Global:Icinga) {
17+
$Global:Icinga = @{ };
18+
}
19+
20+
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
21+
$Global:Icinga.Add('CacheBuilding', $TRUE);
22+
} else {
23+
$Global:Icinga.CacheBuilding = $TRUE;
24+
}
25+
1126
# Ensures that VS Code is not generating the cache file
1227
if ($null -ne $env:TERM_PROGRAM) {
1328
Write-IcingaFrameworkCodeCache -DeveloperMode;
@@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
2237
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
2338
Copy-IcingaFrameworkCacheTemplate;
2439
}
40+
41+
$Global:Icinga.CacheBuilding = $FALSE;

0 commit comments

Comments
 (0)