Check for 404 before downloading

This commit is contained in:
Nemo 2021-12-04 13:46:54 +05:30
parent a767f5a56c
commit 01fdcce73e
1 changed files with 12 additions and 1 deletions

View File

@ -76,6 +76,15 @@ function get_versions() {
return $versions;
}
function release_exists($url) {
exec("curl --silent -I -o /dev/null -w '%{http_code}' $url", $output);
if (trim($output[0]) == '404') {
return false;
} else {
return true;
}
}
foreach(get_versions() as $version) {
foreach($oses as $os) {
foreach($archs as $arch) {
@ -105,7 +114,9 @@ foreach(get_versions() as $version) {
$url = "https://github.com/electron/electron/releases/download/$version/electron-$version-$os-$arch.zip";
echo $url . PHP_EOL;
if (download_release($url, $zipfile)) {
if (!release_exists($url)) {
echo "[DL:404] $url\n";
} else if (download_release($url, $zipfile)) {
extract_release($zipfile, $output);
generateFingerprint($version, $output, $hash_file);
} else {