Skip to content

Commit 8351930

Browse files
committed
fix: downloads.php.net CDN unreliable, and no longer allows range queries
1 parent a39b6ad commit 8351930

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/DownloadLinkFetcher.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getLinksForTag(string $tag): array {
2121
$file = basename($link);
2222
$return[$type] = [
2323
'url' => $link,
24-
'size' => $urlStatus[$link],
24+
'size' => $urlStatus[$link] === 0 ? null : $urlStatus[$link],
2525
'sha256' => isset($this->hashes[$file]) ? $this->hashes[$file]['sha256'] : null,
2626
];
2727
}
@@ -75,7 +75,7 @@ private function ensureReleasesJson(): void {
7575
}
7676

7777
private function ingestHashList(string $url, &$hashes): void {
78-
$releasesJson = file_get_contents(self::RELEASES_JSON);
78+
$releasesJson = file_get_contents($url);
7979
$releases = json_decode($releasesJson, associative: true, depth: 10, flags: JSON_THROW_ON_ERROR);
8080

8181
foreach ($releases as $version_ => $files) {
@@ -171,7 +171,8 @@ private function getMultiUrlStatus(array $urlsets): array {
171171

172172
foreach ($handlers as $urls) {
173173
foreach ($urls as $url) {
174-
if (curl_getinfo($url, CURLINFO_HTTP_CODE) === 206) {
174+
$httpStatus = curl_getinfo($url, CURLINFO_HTTP_CODE);
175+
if ($httpStatus === 200 || $httpStatus === 206) {
175176
$completedUrls[curl_getinfo($url, CURLINFO_EFFECTIVE_URL)] = curl_multi_getcontent($url);
176177
}
177178
curl_multi_remove_handle($cm, $url);
@@ -184,10 +185,10 @@ private function getMultiUrlStatus(array $urlsets): array {
184185
preg_match('/content-range: bytes \d+-\d+\/(?<size>\d+)\b/i', $headers, $matches);
185186
if (!empty($matches['size'])) {
186187
$headers = $matches['size'];
188+
continue;
187189
}
188-
else {
189-
throw new \LogicException('Content-range not matched');
190-
}
190+
191+
$headers = 0;
191192
}
192193

193194
return $completedUrls;

0 commit comments

Comments
 (0)