Catch Curl error when updating projects

This commit is contained in:
Alex Cabal 2025-04-29 12:42:31 -05:00
parent 0490ba2951
commit 6c5caa2642

View file

@ -574,20 +574,25 @@ final class Project{
return; return;
} }
$curl = curl_init($this->VcsUrl); try{
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, Enums\HttpMethod::Head->value); // Only perform HTTP HEAD. $curl = curl_init($this->VcsUrl);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, Enums\HttpMethod::Head->value); // Only perform HTTP HEAD.
curl_exec($curl); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_exec($curl);
/** @var string $finalUrl */ /** @var string $finalUrl */
$finalUrl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL); $finalUrl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
// Were we redirected? // Were we redirected?
if($finalUrl != $this->VcsUrl){ if($finalUrl != $this->VcsUrl){
$this->VcsUrl = $finalUrl; $this->VcsUrl = $finalUrl;
}
$this->IsVcsUrlUpdated = true;
}
catch(Safe\Exceptions\CurlException){
// Probably a temporary failure, just continue but don't mark the URL as having been updated.
} }
$this->IsVcsUrlUpdated = true;
} }
/** /**