From b6efc1db796a6be89f5f72a7c9485a31e1b99361 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 20 Mar 2014 17:44:58 +0100 Subject: Fix handle leak in downloading, better error reporting on failed downloads, add nvidia_libs addon to downloads --- inc/util.inc.php | 6 ++++-- modules/minilinux.inc.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/inc/util.inc.php b/inc/util.inc.php index 277dde31..67e4b73d 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -101,7 +101,9 @@ class Util private static function getContents($fh) { fseek($fh, 0, SEEK_SET); - return fread($fh, 10000); + $data = fread($fh, 10000); + fclose($fh); + return $data; } /** @@ -144,7 +146,7 @@ class Util if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) { $code = (int)$out[1]; } else { - $code = 999; + $code = '999 ' . curl_error($ch); } return true; } diff --git a/modules/minilinux.inc.php b/modules/minilinux.inc.php index 49e72616..72af0eb4 100644 --- a/modules/minilinux.inc.php +++ b/modules/minilinux.inc.php @@ -15,6 +15,7 @@ function render_module() checkFile($files, 'initramfs-stage31'); checkFile($files, 'stage32.sqfs'); checkFile($files, 'vmware.sqfs'); + checkFile($files, 'nvidia_libs.sqfs'); Render::addTemplate('page-minilinux', array('files' => $files, 'token' => Session::get('token'))); } @@ -65,7 +66,7 @@ function checkFile(&$files, $name) $remoteMd5 = Util::download($remote, 3, $code); $remoteMd5 = strtolower(preg_replace('/[^0-9a-f]/is', '', $remoteMd5)); if ($code != 200) { - Message::addError('remote-timeout', $remote); + Message::addError('remote-timeout', $remote, $code); return false; } if ($existingMd5 === $remoteMd5) { -- cgit v1.2.3-55-g7522