mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-09-29 08:47:10 +00:00
add support for sha512 hashes / autoupdate custom hash type support
This commit is contained in:
+7
-3
@@ -57,13 +57,17 @@ function getHash([String] $app, $config, [String] $version, [String] $url)
|
||||
$hashfile_url = substitute $config.url @{'$version' = $version; '$url' = $url};
|
||||
$hashfile = (new-object net.webclient).downloadstring($hashfile_url)
|
||||
|
||||
$regex = substitute $config.find @{'$basename' = [regex]::Escape($basename)}
|
||||
$regex = $config.find
|
||||
if ($regex -eq $null) {
|
||||
$regex = "([a-z0-9]+)"
|
||||
}
|
||||
$regex = substitute $regex @{'$basename' = [regex]::Escape($basename)}
|
||||
|
||||
if ($hashfile -match $regex) {
|
||||
$hash = $matches[1]
|
||||
|
||||
if ($config.type -eq "sha1") {
|
||||
$hash = "sha1:$hash"
|
||||
if ($config.type -and !($config.type -eq "sha256")) {
|
||||
$hash = $config.type + ":$hash"
|
||||
}
|
||||
}
|
||||
} elseif ($hashmode -eq "download") {
|
||||
|
||||
+1
-1
@@ -340,7 +340,7 @@ function check_hash($file, $url, $manifest, $arch) {
|
||||
$type, $expected = 'sha256', $type
|
||||
}
|
||||
|
||||
if(@('md5','sha1','sha256') -notcontains $type) {
|
||||
if(@('md5','sha1','sha256', 'sha512') -notcontains $type) {
|
||||
return $false, "hash type $type isn't supported"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user