Fix crash while trying to update with identical current and target version

Fixes #50
This commit is contained in:
Christian Stein 2020-03-10 17:28:22 +01:00
parent a45d0e2fbb
commit 77ebfc431f
3 changed files with 21 additions and 1 deletions

View file

@ -26,7 +26,14 @@ function Get-IcingaPowerShellModuleArchive()
if ($null -ne $CurrentVersion -And $CurrentVersion -eq $Tag) { if ($null -ne $CurrentVersion -And $CurrentVersion -eq $Tag) {
Write-Host ([string]::Format('Your "{0}" is already up-to-date', $ModuleName)); Write-Host ([string]::Format('Your "{0}" is already up-to-date', $ModuleName));
return; return @{
'DownloadUrl' = $DownloadUrl;
'Version' = $Tag;
'Directory' = '';
'Archive' = '';
'ModuleRoot' = (Get-IcingaFrameworkRootPath);
'Installed' = $FALSE;
};
} }
} }
} else { } else {
@ -56,5 +63,6 @@ function Get-IcingaPowerShellModuleArchive()
'Directory' = $DownloadDirectory; 'Directory' = $DownloadDirectory;
'Archive' = $DownloadDestination; 'Archive' = $DownloadDestination;
'ModuleRoot' = (Get-IcingaFrameworkRootPath); 'ModuleRoot' = (Get-IcingaFrameworkRootPath);
'Installed' = $TRUE;
}; };
} }

View file

@ -7,6 +7,12 @@ function Install-IcingaFrameworkPlugins()
$RepositoryName = 'icinga-powershell-plugins'; $RepositoryName = 'icinga-powershell-plugins';
$Archive = Get-IcingaPowerShellModuleArchive -DownloadUrl $PluginsUrl -ModuleName 'Icinga Plugins' -Repository $RepositoryName; $Archive = Get-IcingaPowerShellModuleArchive -DownloadUrl $PluginsUrl -ModuleName 'Icinga Plugins' -Repository $RepositoryName;
if ($Archive.Installed -eq $FALSE) {
return @{
'PluginUrl' = $Archive.DownloadUrl
};
}
Write-Host ([string]::Format('Installing module into "{0}"', ($Archive.Directory))); Write-Host ([string]::Format('Installing module into "{0}"', ($Archive.Directory)));
Expand-IcingaZipArchive -Path $Archive.Archive -Destination $Archive.Directory | Out-Null; Expand-IcingaZipArchive -Path $Archive.Archive -Destination $Archive.Directory | Out-Null;

View file

@ -7,6 +7,12 @@ function Install-IcingaFrameworkUpdate()
$RepositoryName = 'icinga-powershell-framework'; $RepositoryName = 'icinga-powershell-framework';
$Archive = Get-IcingaPowerShellModuleArchive -DownloadUrl $FrameworkUrl -ModuleName 'Icinga Framework' -Repository $RepositoryName; $Archive = Get-IcingaPowerShellModuleArchive -DownloadUrl $FrameworkUrl -ModuleName 'Icinga Framework' -Repository $RepositoryName;
if ($Archive.Installed -eq $FALSE) {
return @{
'PluginUrl' = $Archive.DownloadUrl
};
}
Write-Host ([string]::Format('Installing module into "{0}"', ($Archive.Directory))); Write-Host ([string]::Format('Installing module into "{0}"', ($Archive.Directory)));
Expand-IcingaZipArchive -Path $Archive.Archive -Destination $Archive.Directory | Out-Null; Expand-IcingaZipArchive -Path $Archive.Archive -Destination $Archive.Directory | Out-Null;