From a9eb6aa820d2790a5b1ef8d3711d6131c9885352 Mon Sep 17 00:00:00 2001 From: Hani Rouatbi <23016064+hanirouatbi1@users.noreply.github.com> Date: Thu, 25 Aug 2022 18:42:16 +0100 Subject: [PATCH] Update FetchFile.php --- includes/FetchFile.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/FetchFile.php b/includes/FetchFile.php index fd67563..9ad4391 100644 --- a/includes/FetchFile.php +++ b/includes/FetchFile.php @@ -124,29 +124,31 @@ class FetchFile $out = fopen($this->destinationPath, 'w'); curl_setopt($ch, CURLOPT_FILE, $out); $result = curl_exec($ch); - curl_close($ch); - fclose($out); if ($result === false) { + $error = true; kleeja_log(sprintf("cUrl error (#%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch)))); - return false; } + + curl_close($ch); + fclose($out); - return true; + return isset($error) ? false : true; } else { $data = curl_exec($ch); - curl_close($ch); if ($data === false) { + $error = true; kleeja_log(sprintf("FetchFile error (curl: #%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch)))); - return false; } + + curl_close($ch); - return $data; + return isset($error) ? false : $data; } }