Пример #1
0
 public function testFetchAllWithInstallButFileExists()
 {
     list($opp, $pp) = $this->createProphecies();
     $pp->getName()->willReturn('');
     $pp->getDistType()->willReturn('html');
     $pp->getDistUrl()->willReturn('http://example.com/');
     $pp->getDistMirrors()->willReturn(array());
     $pp->getSourceUrl()->willReturn('git://uso800');
     $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . FileDownloaderDummy::getCacheKeyCompat($pp->reveal(), 'http://example.com/');
     $fp = fopen($path, 'wb');
     $opp->getPackage()->willReturn($pp->reveal())->shouldBeCalled();
     $fetcher = new Prefetcher();
     $fetcher->fetchAllFromOperations($this->iop->reveal(), $this->configp->reveal(), array($opp->reveal()));
     fclose($fp);
     unlink($path);
 }
 protected function preloadProviderListings($data)
 {
     if ($this->providersUrl && isset($data['provider-includes'])) {
         $includes = $data['provider-includes'];
         $requests = array();
         $cachedir = $this->config->get('cache-repo-dir');
         $cacheBase = $cachedir . DIRECTORY_SEPARATOR . strtr($this->baseUrl, ':/', '--');
         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']) {
                 $dest = $cacheBase . DIRECTORY_SEPARATOR . str_replace('/', '-', $cacheKey);
                 $requests[] = new CopyRequest($url, $dest, false, $this->io, $this->config);
             }
         }
         if ($requests) {
             $prefetcher = new Prefetcher();
             $prefetcher->fetchAll($this->io, $requests);
         }
     }
 }
Пример #3
0
 /**
  * pre-fetch parallel by curl_multi
  */
 public function onPostDependenciesSolving(Installer\InstallerEvent $ev)
 {
     if ($this->disabled) {
         return;
     }
     $prefetcher = new Prefetcher();
     $prefetcher->fetchAllFromOperations($this->io, $this->config, $ev->getOperations());
 }