Merge pull request #382 from Icinga:fix/repository_hash_generator

Fix: Repository Hash generator

Fixes the hash generator for the repository hash, which always returned the same hash.
This commit is contained in:
Lord Hepipud 2021-10-26 09:07:18 +02:00 committed by GitHub
commit fedc34bbb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#375](https://github.com/Icinga/icinga-powershell-framework/pull/375) Fixes exception on last message printed during `Uninstall-IcingaForWindows`, because the prior used function is no longer present at this point * [#375](https://github.com/Icinga/icinga-powershell-framework/pull/375) Fixes exception on last message printed during `Uninstall-IcingaForWindows`, because the prior used function is no longer present at this point
* [#376](https://github.com/Icinga/icinga-powershell-framework/pull/376) Fixes IMC error handling on invalid JSON for installation command/file * [#376](https://github.com/Icinga/icinga-powershell-framework/pull/376) Fixes IMC error handling on invalid JSON for installation command/file
* [#381](https://github.com/Icinga/icinga-powershell-framework/issues/381) Fixes Repository Hash generator for new repositories, which always returned the same hash regardless of the files inside
## 1.6.1 (2021-09-15) ## 1.6.1 (2021-09-15)

View file

@ -10,10 +10,20 @@ function Get-IcingaRepositoryHash()
} }
$RepositoryFolder = Get-ChildItem -Path $Path -Recurse; $RepositoryFolder = Get-ChildItem -Path $Path -Recurse;
[array]$FileHashes = @(); $FileHashes = New-Object -TypeName 'System.Text.StringBuilder';
foreach ($entry in $RepositoryFolder) { foreach ($entry in $RepositoryFolder) {
$FileHashes += (Get-FileHash -Path $entry.FullName -Algorithm SHA256).Hash; $FileHash = (Get-FileHash -Path $entry.FullName -Algorithm SHA256).Hash;
if ([string]::IsNullOrEmpty($FileHash)) {
continue;
}
if ($FileHashes.Length -ne 0) {
$FileHashes.Append('+') | Out-Null;
}
$FileHashes.Append($FileHash) | Out-Null;
} }
$HashAlgorithm = [System.Security.Cryptography.HashAlgorithm]::Create('SHA256'); $HashAlgorithm = [System.Security.Cryptography.HashAlgorithm]::Create('SHA256');