diff options
author | Chris Buechler <cmb@pfsense.org> | 2016-02-09 15:56:37 -0600 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2016-02-09 15:56:37 -0600 |
commit | fd4dbabc09ddd265f78db8140bdac688651f3575 (patch) | |
tree | 7522e3f4ab0c3dc697857d31c86207a8728b9683 | |
parent | 8283e679c2fdf0ae4d918655c9feb0ade3351780 (diff) | |
download | pfsense-fd4dbabc09ddd265f78db8140bdac688651f3575.zip pfsense-fd4dbabc09ddd265f78db8140bdac688651f3575.tar.gz |
Return false in download_file rather than the failed status code when a download fails. Return would always evaluate to true previously though other parts of the code expect a false value when a download fails. related to Ticket #5848
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 3db6452..07364f2 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -1683,7 +1683,13 @@ function download_file($url, $destination, $verify_ssl = true, $connect_timeout $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); fclose($fp); curl_close($ch); - return ($http_code == 200) ? true : $http_code; + if ($http_code == 200) { + return true; + } else { + log_error("Download file failed with status code $http_code. URL: $url"); + unlink_if_exists($destination); + return false; + } } function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body', $connect_timeout = 5, $timeout = 0) { |