/**
  * New releases can be downloaded via the update api and provide a sha1 hash
  *
  * @param $release
  * @return string
  */
 private function downloadFromUpdateApi($release)
 {
     $indexedReleases = $this->getIndexedReleasesList();
     if (array_key_exists($release, $indexedReleases)) {
         $content = $indexedReleases[$release];
     } else {
         if ($release == 'latest') {
             $content = array_shift($indexedReleases);
         } else {
             throw new \RuntimeException(sprintf("Could not find release %s", $release));
         }
     }
     $version = $content['version'];
     $url = $content['uri'];
     $size = $content['size'];
     $sha1 = $content['sha1'];
     $target = $this->getTempFile();
     $cacheFilePath = $this->getCacheFilePath($version);
     if (file_exists($cacheFilePath)) {
         return $cacheFilePath;
     }
     $this->downloader->download($url, $target);
     $sha1Actual = sha1_file($target);
     if ($sha1 != $sha1Actual) {
         throw new \RuntimeException("Hash mismatch");
     }
     copy($target, $cacheFilePath);
     return $cacheFilePath;
 }
 /**
  * Older releases needs to be installed directly via the s3 url
  *
  * @param  string $release
  * @return string
  */
 private function downloadFromUrl($release)
 {
     $url = $this->getDownloadUrl($release);
     $target = $this->getTempFile();
     $cacheFile = $this->getCacheFilePath($release);
     if (!file_exists($cacheFile)) {
         $this->ioService->writeln("<info>Downloading release {$release}</info>");
         $this->downloader->download($url, $target);
         copy($target, $cacheFile);
     } else {
         $this->ioService->writeln("<info>Reading cached release download for {$release}</info>");
     }
     return $cacheFile;
 }