In case a download fails for whatever reason, and the downloaded file size cannot be determined or is zero, Pakfire should abort.
Signed-off-by: Peter Müller peter.mueller@link38.eu --- src/pakfire/lib/functions.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 12a405bd7..bbc580ad2 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -180,7 +180,14 @@ sub fetchfile { my $result = $ua->head($url); my $remote_headers = $result->headers; $total_size = $remote_headers->content_length; - logger("DOWNLOAD INFO: $file has size of $total_size bytes"); + + # validate if file download was successful (size <= 0) + if ( $total_size eq "0" || not $total_size ) { + logger("DOWNLOAD ERROR: download of $file failed with size '$total_size' bytes"); + return 1; + } else { + logger("DOWNLOAD INFO: $file has size of $total_size bytes"); + } my $response = $ua->get($url, ':content_cb' => &callback ); message("");
Using an array for setting both HTTP and HTTPS proxy settings in functions.pl does not seem to work, the queries are still transferred directly.
Setting proxies with two code lines is boilerplate-style, but works much more robust.
Partially fixes #11900
Signed-off-by: Peter Müller peter.mueller@link38.eu --- src/pakfire/lib/functions.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index bbc580ad2..291a111b9 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -157,10 +157,12 @@ sub fetchfile { if ($proxysettings{'UPSTREAM_PROXY'}) { logger("DOWNLOAD INFO: Upstream proxy: "$proxysettings{'UPSTREAM_PROXY'}""); if ($proxysettings{'UPSTREAM_USER'}) { - $ua->proxy([["http", "https"] => "http://$proxysettings%7B%27UPSTREAM_USER%27%7D:$proxysettings%7B%27UPSTREAM_..."]); + $ua->proxy("http" => "http://$proxysettings%7B%27UPSTREAM_USER%27%7D:$proxysettings%7B%27UPSTREAM_..."); + $ua->proxy("https" => "http://$proxysettings%7B%27UPSTREAM_USER%27%7D:$proxysettings%7B%27UPSTREAM_..."); logger("DOWNLOAD INFO: Logging in with: "$proxysettings{'UPSTREAM_USER'}" - "$proxysettings{'UPSTREAM_PASSWORD'}""); } else { - $ua->proxy([["http", "https"] => "http://$proxysettings%7B%27UPSTREAM_PROXY%27%7D/"]); + $ua->proxy("http" => "http://$proxysettings%7B%27UPSTREAM_PROXY%27%7D/"); + $ua->proxy("https" => "http://$proxysettings%7B%27UPSTREAM_PROXY%27%7D/"); } }