Skip to content

Commit fedc34b

Browse files
authored
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.
2 parents 30ea537 + 234b771 commit fedc34b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/100-General/10-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1515

1616
* [#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
1717
* [#376](https://github.com/Icinga/icinga-powershell-framework/pull/376) Fixes IMC error handling on invalid JSON for installation command/file
18+
* [#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
1819

1920
## 1.6.1 (2021-09-15)
2021

lib/core/repository/Get-IcingaRepositoryHash.psm1

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ function Get-IcingaRepositoryHash()
99
return;
1010
}
1111

12-
$RepositoryFolder = Get-ChildItem -Path $Path -Recurse;
13-
[array]$FileHashes = @();
12+
$RepositoryFolder = Get-ChildItem -Path $Path -Recurse;
13+
$FileHashes = New-Object -TypeName 'System.Text.StringBuilder';
1414

1515
foreach ($entry in $RepositoryFolder) {
16-
$FileHashes += (Get-FileHash -Path $entry.FullName -Algorithm SHA256).Hash;
16+
$FileHash = (Get-FileHash -Path $entry.FullName -Algorithm SHA256).Hash;
17+
18+
if ([string]::IsNullOrEmpty($FileHash)) {
19+
continue;
20+
}
21+
22+
if ($FileHashes.Length -ne 0) {
23+
$FileHashes.Append('+') | Out-Null;
24+
}
25+
26+
$FileHashes.Append($FileHash) | Out-Null;
1727
}
1828

1929
$HashAlgorithm = [System.Security.Cryptography.HashAlgorithm]::Create('SHA256');

0 commit comments

Comments
 (0)