mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
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:
commit
d91500fa4b
4 changed files with 43 additions and 1 deletions
17
cache/framework_cache.psm1
vendored
17
cache/framework_cache.psm1
vendored
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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', @{ });
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue