Merge pull request #7574 from seferov/patch-1
Remove github API request retries as it is not needed anymorepull/7454/head
commit
734735c691
|
@ -183,30 +183,13 @@ class GitHubDriver extends VcsDriver
|
||||||
return $this->gitDriver->getFileContent($file, $identifier);
|
return $this->gitDriver->getFileContent($file, $identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notFoundRetries = 2;
|
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
|
||||||
while ($notFoundRetries) {
|
$resource = JsonFile::parseJson($this->getContents($resource));
|
||||||
try {
|
if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
|
||||||
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
|
throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
|
||||||
$resource = JsonFile::parseJson($this->getContents($resource));
|
|
||||||
if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
|
|
||||||
throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
} catch (TransportException $e) {
|
|
||||||
if (404 !== $e->getCode()) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO should be removed when possible
|
|
||||||
// retry fetching if github returns a 404 since they happen randomly
|
|
||||||
$notFoundRetries--;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue