Skip to content

Commit

Permalink
Merge pull request #7895 from kaltura/Naos-14.10.0-KCurlWrapperFixNot…
Browse files Browse the repository at this point in the history
…ices

No-Plat: If destFile provided and we failed to open it return error result
  • Loading branch information
yossipapi committed Dec 4, 2018
2 parents 95aae03 + 0297c9e commit e536a24
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions infra/general/KCurlWrapper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class KCurlWrapper
const LOW_SPEED_TIME_LIMIT = 595; //595 sec + 5 sec until it is detected total is 600 sec = 10 min

const HTTP_USER_AGENT = "\"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6\"";

const ERROR_CODE_FAILED_TO_OPEN_FILE_FOR_WRITING = 37;

/**
* @var resource
Expand Down Expand Up @@ -551,7 +553,15 @@ public function exec($sourceUrl, $destFile = null,$progressCallBack = null, $all
$returnTransfer = is_null($destFile);
$destFd = null;
if (!is_null($destFile))
{
$destFd = fopen($destFile, "ab");
if($destFd === false)
{
KalturaLog::debug("Exec Curl - Failed opening file [$destFile] for writing");
$this->setFailedOpeningFileErrorResults($destFile);
return false;
}
}

curl_setopt($this->ch, CURLOPT_HEADER, false);
curl_setopt($this->ch, CURLOPT_NOBODY, false);
Expand Down Expand Up @@ -599,6 +609,12 @@ private function setInternalUrlErrorResults($url)
$this->errorNumber = -1;
$this->error = "Internal not allowed url [$url] - curl will not be invoked";
}

protected function setFailedOpeningFileErrorResults($filePath)
{
$this->errorNumber = self::ERROR_CODE_FAILED_TO_OPEN_FILE_FOR_WRITING;
$this->error = "Failed opening file [$filePath]";
}

private function execCurl()
{
Expand Down

0 comments on commit e536a24

Please sign in to comment.