Skip to content

Commit

Permalink
those buggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Apr 20, 2024
1 parent 09a3842 commit edd3a36
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions bin/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,30 @@ function is_dir_empty(string $dir): bool
}

if ($download) {
echo 'Downloading ' . $version . ' from ' . $url . PHP_EOL;
// Download/extract ZIP file
if (!copy($url, $zip_file_name)) {
echo "Unable to download.\n";
// Download zip file...
echo sprintf('Downloading %s from %s%s', $version, $url, PHP_EOL);
$fh = fopen($zip_file_name, 'w');
$ch = curl_init($url);
curl_setopt_array(
$ch,
[
CURLOPT_USERAGENT => 'Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0',
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => 0,
CURLOPT_FILE => $fh,
]
);
$resp = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);
fclose($fh);
if ('' !== $err) {
echo sprintf('Error downloading from %s: %s%s', $version, $err, PHP_EOL);
exit(1);
}
if ($code !== 200) {
echo sprintf('Error downlodaing from %s: %d (%s)%s', $version, $code, $resp, PHP_EOL);
exit(1);
}
}
Expand Down

0 comments on commit edd3a36

Please sign in to comment.