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; } }