1
0
Fork 0

Merge pull request #9177 from simonberger/reduce-requests

Re-Fetch cached packages only once in a run
pull/9188/head
Jordi Boggiano 2020-09-07 17:01:46 +02:00 committed by GitHub
commit 8694077564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 9 deletions

View File

@ -43,7 +43,6 @@ use React\Promise\Promise;
*/ */
class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{ {
private $config;
private $repoConfig; private $repoConfig;
private $options; private $options;
private $url; private $url;
@ -102,7 +101,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
$repoConfig['url'] = rtrim($repoConfig['url'], '/'); $repoConfig['url'] = rtrim($repoConfig['url'], '/');
if ('https?' === substr($repoConfig['url'], 0, 6)) { if (strpos($repoConfig['url'], 'https?') === 0) {
$repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6); $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
} }
@ -118,7 +117,6 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$this->allowSslDowngrade = true; $this->allowSslDowngrade = true;
} }
$this->config = $config;
$this->options = $repoConfig['options']; $this->options = $repoConfig['options'];
$this->url = $repoConfig['url']; $this->url = $repoConfig['url'];
@ -570,13 +568,12 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} elseif ($useLastModifiedCheck) { } elseif ($useLastModifiedCheck) {
if ($contents = $this->cache->read($cacheKey)) { if ($contents = $this->cache->read($cacheKey)) {
$contents = json_decode($contents, true); $contents = json_decode($contents, true);
if (isset($contents['last-modified'])) { // we already loaded some packages from this file, so assume it is fresh and avoid fetching it again
if (isset($alreadyLoaded[$name])) {
$packages = $contents;
} elseif (isset($contents['last-modified'])) {
$response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']); $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
if (true === $response) { $packages = true === $response ? $contents : $response;
$packages = $contents;
} elseif ($response) {
$packages = $response;
}
} }
} }
} }