Prefer SHA-512 for Modrinth, add rehash command

This commit is contained in:
Una Thompson
2023-10-03 18:26:21 -07:00
parent ef049968b1
commit e1508134c7
2 changed files with 93 additions and 6 deletions

View File

@@ -361,12 +361,9 @@ func shouldDownloadOnSide(side string) bool {
}
func getBestHash(v *modrinthApi.File) (string, string) {
// Try preferred hashes first; SHA1 is first as it is required for Modrinth pack exporting
val, exists := v.Hashes["sha1"]
if exists {
return "sha1", val
}
val, exists = v.Hashes["sha512"]
// Try preferred hashes first; SHA1 is required for Modrinth pack exporting, but
// so is SHA512, so we can't win with the current one-hash format
val, exists := v.Hashes["sha512"]
if exists {
return "sha512", val
}
@@ -374,6 +371,10 @@ func getBestHash(v *modrinthApi.File) (string, string) {
if exists {
return "sha256", val
}
val, exists = v.Hashes["sha1"]
if exists {
return "sha1", val
}
val, exists = v.Hashes["murmur2"] // (not defined in Modrinth pack spec, use with caution)
if exists {
return "murmur2", val