better download errors

This commit is contained in:
Robin Appelman 2025-10-27 00:47:35 +01:00
commit de70afa7e8
2 changed files with 19 additions and 7 deletions

Binary file not shown.

View file

@ -133,9 +133,9 @@ public onComplete(Handle:hndl, CURLcode:code, any hDLPack) {
ReadPackString(hDLPack, map, sizeof(map)); ReadPackString(hDLPack, map, sizeof(map));
ReadPackString(hDLPack, targetPath, sizeof(targetPath)); ReadPackString(hDLPack, targetPath, sizeof(targetPath));
CloseHandle(hDLPack); CloseHandle(hDLPack);
CloseHandle(hndl);
if (code != CURLE_OK) { if (code != CURLE_OK) {
CloseHandle(hndl);
PrintToChatAll("Error downloading map %s", map); PrintToChatAll("Error downloading map %s", map);
decl String:sError[256]; decl String:sError[256];
curl_easy_strerror(code, sError, sizeof(sError)); curl_easy_strerror(code, sError, sizeof(sError));
@ -143,7 +143,11 @@ public onComplete(Handle:hndl, CURLcode:code, any hDLPack) {
PrintToChatAll("cURL error code: %d", code); PrintToChatAll("cURL error code: %d", code);
DeleteFile(targetPath); DeleteFile(targetPath);
} else { } else {
//PrintToChatAll("map size(%s): %d", targetPath, FileSize(targetPath)); new status_code;
curl_easy_getinfo_int(hndl, CURLINFO_RESPONSE_CODE, status_code);
CloseHandle(hndl);
if (status_code == 200) {
if (FileSize(targetPath) < 1024) { if (FileSize(targetPath) < 1024) {
PrintToChatAll("Map file to small, discarding"); PrintToChatAll("Map file to small, discarding");
DeleteFile(targetPath); DeleteFile(targetPath);
@ -151,6 +155,14 @@ public onComplete(Handle:hndl, CURLcode:code, any hDLPack) {
} }
PrintToChatAll("Successfully downloaded map %s", map); PrintToChatAll("Successfully downloaded map %s", map);
changeLevel(map); changeLevel(map);
} else if (status_code == 404) {
PrintToChatAll("Map %s not found", map);
DeleteFile(targetPath);
} else {
DeleteFile(targetPath);
PrintToChatAll("Error downloading map %s", map);
PrintToChatAll("HTTP error: %d", status_code);
}
} }
return; return;
} }