Skip to content

Commit

Permalink
Merge pull request #26 from huangzhhui/master
Browse files Browse the repository at this point in the history
Add exception for empty download url
  • Loading branch information
huangzhhui authored Sep 28, 2022
2 parents f31919c + 510dd43 commit 05e587b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/DownloadHandler/AbstractDownloadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ protected function fetchDownloadUrlFromGithubRelease(string $assetName, string $
$release = $this->githubClient->getRelease($fullRepo, $version);
$url = null;
foreach ($release['assets'] ?? [] as $asset) {
if ($asset['name'] === $assetName) {
if ($asset['name'] === $assetName && $asset['browser_download_url']) {
$url = $asset['browser_download_url'];
}
}
return $url;
}

protected function download(
string $url,
?string $url,
string $savePath,
int $permissions,
string $renameTo = ''
): SplFileInfo {
if (! $url) {
throw new \RuntimeException('Download url is empty, maybe the url parse failed.');
}
$this->logger->info(sprintf('Downloading %s', $url));
if (str_ends_with($savePath, '/')) {
$explodedUrl = explode('/', $url);
Expand Down

0 comments on commit 05e587b

Please sign in to comment.