1
0
Fork 0

Add support for the hashed provider includes

pull/1609/head
Jordi Boggiano 2013-02-21 18:51:22 +01:00
parent 2c4c5dd764
commit d4c9a9004a
1 changed files with 11 additions and 2 deletions

View File

@ -392,11 +392,20 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
if ($this->providersUrl && isset($data['provider-includes'])) { if ($this->providersUrl && isset($data['provider-includes'])) {
$includes = $data['provider-includes']; $includes = $data['provider-includes'];
foreach ($includes as $include => $metadata) {
$url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
$cacheKey = str_replace(array('%hash%','$'), '', $include);
if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
$includedData = json_decode($this->cache->read($cacheKey), true);
} else {
$includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
}
$this->loadProviderListings($includedData);
}
} elseif (isset($data['providers-includes'])) { } elseif (isset($data['providers-includes'])) {
// BC layer for old-style providers-includes // BC layer for old-style providers-includes
$includes = $data['providers-includes']; $includes = $data['providers-includes'];
}
if (!empty($includes)) {
foreach ($includes as $include => $metadata) { foreach ($includes as $include => $metadata) {
if ($this->cache->sha256($include) === $metadata['sha256']) { if ($this->cache->sha256($include) === $metadata['sha256']) {
$includedData = json_decode($this->cache->read($include), true); $includedData = json_decode($this->cache->read($include), true);