Retry fetching composer.json files twice since github returns 404s at random at the moment

@bhuga confirmed it is the best approach until github finds a fix. /cc @gillesruppert enjoy whatever your bet wins you
main
Jordi Boggiano 11 years ago
parent 3f2b9b4d4b
commit 5267bafa2c

@ -127,18 +127,25 @@ class GitHubDriver extends VcsDriver
} }
if (!isset($this->infoCache[$identifier])) { if (!isset($this->infoCache[$identifier])) {
try { $notFoundRetries = 2;
$resource = 'https://api.github.com/repos/'.$this->owner.'/'.$this->repository.'/contents/composer.json?ref='.urlencode($identifier); while ($notFoundRetries) {
$composer = JsonFile::parseJson($this->getContents($resource)); try {
if (empty($composer['content']) || $composer['encoding'] !== 'base64' || !($composer = base64_decode($composer['content']))) { $resource = 'https://api.github.com/repos/'.$this->owner.'/'.$this->repository.'/contents/composer.json?ref='.urlencode($identifier);
throw new \RuntimeException('Could not retrieve composer.json from '.$resource); $composer = JsonFile::parseJson($this->getContents($resource));
} if (empty($composer['content']) || $composer['encoding'] !== 'base64' || !($composer = base64_decode($composer['content']))) {
} catch (TransportException $e) { throw new \RuntimeException('Could not retrieve composer.json from '.$resource);
if (404 !== $e->getCode()) { }
throw $e; break;
} } catch (TransportException $e) {
if (404 !== $e->getCode()) {
throw $e;
}
$composer = false; // TODO should be removed when possible
// retry fetching if github returns a 404 since they happen randomly
$notFoundRetries--;
$composer = false;
}
} }
if ($composer) { if ($composer) {

Loading…
Cancel
Save