From 23e39fd0a377eb99b4c29e5ba4c02dfffd3a040f Mon Sep 17 00:00:00 2001 From: Hani Rouatbi <23016064+hanirouatbi1@users.noreply.github.com> Date: Thu, 25 Aug 2022 17:50:33 +0100 Subject: [PATCH] Update FetchFile.php --- includes/FetchFile.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/FetchFile.php b/includes/FetchFile.php index 8f8ff7b..fd67563 100644 --- a/includes/FetchFile.php +++ b/includes/FetchFile.php @@ -124,26 +124,27 @@ 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) { kleeja_log(sprintf("cUrl error (#%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch)))); + return false; } - curl_close($ch); - fclose($out); - return true; } else { $data = curl_exec($ch); + curl_close($ch); if ($data === false) { kleeja_log(sprintf("FetchFile error (curl: #%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch)))); + return false; } - curl_close($ch); return $data; }