Merge pull request #9177 from simonberger/reduce-requests
Re-Fetch cached packages only once in a runpull/9188/head
commit
8694077564
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue