|
1 | 1 | # Description: Functions for downloading files |
2 | 2 |
|
3 | 3 | . "$PSScriptRoot\..\lib\core.ps1" |
| 4 | +. "$PSScriptRoot\..\lib\hash.ps1" # 'hash_for_url' |
4 | 5 | . "$PSScriptRoot\..\lib\virustotal.ps1" |
5 | 6 |
|
6 | 7 | ## Meta downloader |
@@ -733,21 +734,6 @@ function url_remote_filename($url) { |
733 | 734 | return $basename |
734 | 735 | } |
735 | 736 |
|
736 | | -### Hash-related functions |
737 | | - |
738 | | -function hash_for_url($manifest, $url, $arch) { |
739 | | - $hashes = @(hash $manifest $arch) | Where-Object { $_ -ne $null } |
740 | | - |
741 | | - if ($hashes.length -eq 0) { return $null } |
742 | | - |
743 | | - $urls = @(script:url $manifest $arch) |
744 | | - |
745 | | - $index = [array]::IndexOf($urls, $url) |
746 | | - if ($index -eq -1) { abort "Couldn't find hash in manifest for '$url'." } |
747 | | - |
748 | | - @($hashes)[$index] |
749 | | -} |
750 | | - |
751 | 737 | function check_hash($file, $hash, $app_name) { |
752 | 738 | # returns (ok, err) |
753 | 739 | if (!$hash) { |
@@ -783,19 +769,5 @@ function check_hash($file, $hash, $app_name) { |
783 | 769 | return $true, $null |
784 | 770 | } |
785 | 771 |
|
786 | | -function get_hash([String] $multihash) { |
787 | | - $type, $hash = $multihash -split ':' |
788 | | - if (!$hash) { |
789 | | - # no type specified, assume sha256 |
790 | | - $type, $hash = 'sha256', $multihash |
791 | | - } |
792 | | - |
793 | | - if (@('md5', 'sha1', 'sha256', 'sha512') -notcontains $type) { |
794 | | - return $null, "Hash type '$type' isn't supported." |
795 | | - } |
796 | | - |
797 | | - return $type, $hash.ToLower() |
798 | | -} |
799 | | - |
800 | 772 | # Setup proxy globally |
801 | 773 | setup_proxy |
0 commit comments