mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-09-22 21:35:56 +00:00
FTP SIZE request
Came across this when tried to install zip. ContentLength is -1 when downloading from their server.
This commit is contained in:
@@ -170,6 +170,9 @@ function dl($url, $to, $cookies, $progress) {
|
||||
|
||||
$wres = $wreq.getresponse()
|
||||
$total = $wres.ContentLength
|
||||
if($total -eq -1 -and $wreq -is [net.ftpwebrequest]) {
|
||||
$total = ftp_file_size($url)
|
||||
}
|
||||
|
||||
if ($progress -and ($total -gt 0)) {
|
||||
[console]::CursorVisible = $false
|
||||
@@ -424,6 +427,12 @@ function is_in_dir($dir, $check) {
|
||||
$check -match "^$([regex]::escape("$dir"))(\\|`$)"
|
||||
}
|
||||
|
||||
function ftp_file_size($url) {
|
||||
$request = [net.ftpwebrequest]::create($url)
|
||||
$request.method = [net.webrequestmethods+ftp]::getfilesize
|
||||
$request.getresponse().contentlength
|
||||
}
|
||||
|
||||
# hashes
|
||||
function hash_for_url($manifest, $url, $arch) {
|
||||
$hashes = @(hash $manifest $arch) | ? { $_ -ne $null };
|
||||
|
||||
Reference in New Issue
Block a user