Shopware\Install\Services\ReleaseDownloader::downloadFromUpdateApi PHP Method

downloadFromUpdateApi() private method

New releases can be downloaded via the update api and provide a sha1 hash
private downloadFromUpdateApi ( $release ) : string
$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'];
        $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;
    }