Merge pull request #620 from Icinga:fix/prevent_recursive_looping_on_first_framework_initialisation

Fix: Recursive loop on first loading of Framework

Prevents the Icinga for Windows framework to recursively import itself on first startup or after reseting the cache file.
This commit is contained in:
Lord Hepipud 2023-05-23 16:12:41 +02:00 committed by GitHub
commit d91500fa4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 1 deletions

View file

@ -8,6 +8,21 @@
Manually enabling the feature is no longer required.
#>
# Ensure we only load this module once
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
return;
}
if ($null -eq $Global:Icinga) {
$Global:Icinga = @{ };
}
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $TRUE);
} else {
$Global:Icinga.CacheBuilding = $TRUE;
}
# Ensures that VS Code is not generating the cache file
if ($null -ne $env:TERM_PROGRAM) {
Write-IcingaFrameworkCodeCache -DeveloperMode;
@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate;
}
$Global:Icinga.CacheBuilding = $FALSE;

View file

@ -132,7 +132,11 @@ function Write-IcingaFrameworkCodeCache()
[System.IO.File]::WriteAllLines($CacheFile, $CacheContent, (New-Object System.Text.UTF8Encoding $TRUE));
Remove-IcingaFrameworkDependencyFile;
$DependencyFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework_dependencies.json';
if ((Test-Path $DependencyFile)) {
Remove-Item -Path $DependencyFile -Force | Out-Null;
}
if ($Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate;

View file

@ -15,6 +15,10 @@ function New-IcingaEnvironmentVariable()
$Global:Icinga = @{ };
}
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $FALSE);
}
# Session specific configuration for this shell
if ($Global:Icinga.ContainsKey('Private') -eq $FALSE) {
$Global:Icinga.Add('Private', @{ });

View file

@ -8,6 +8,21 @@
Manually enabling the feature is no longer required.
#>
# Ensure we only load this module once
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
return;
}
if ($null -eq $Global:Icinga) {
$Global:Icinga = @{ };
}
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $TRUE);
} else {
$Global:Icinga.CacheBuilding = $TRUE;
}
# Ensures that VS Code is not generating the cache file
if ($null -ne $env:TERM_PROGRAM) {
Write-IcingaFrameworkCodeCache -DeveloperMode;
@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate;
}
$Global:Icinga.CacheBuilding = $FALSE;