mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-23 04:52:07 +00:00
Rework HTTP download console output.
We're printing only the two relevant informations: A download was queued and a download finished or failed. That's enough to see what's going on and not too noisy.
This commit is contained in:
parent
29f9f48a06
commit
0ad406a95f
2 changed files with 22 additions and 39 deletions
|
@ -181,7 +181,7 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl)
|
||||||
|
|
||||||
if (!dl->file)
|
if (!dl->file)
|
||||||
{
|
{
|
||||||
Com_Printf("CL_StartHTTPDownload: Couldn't open %s for writing.\n", dl->filePath);
|
Com_Printf("HTTP download: Couldn't open %s for writing\n", dl->filePath);
|
||||||
entry->state = DLQ_STATE_DONE;
|
entry->state = DLQ_STATE_DONE;
|
||||||
pendingCount--;
|
pendingCount--;
|
||||||
|
|
||||||
|
@ -204,7 +204,6 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl)
|
||||||
Com_sprintf(dl->URL, sizeof(dl->URL), "%s%s", cls.downloadServer, escapedFilePath);
|
Com_sprintf(dl->URL, sizeof(dl->URL), "%s%s", cls.downloadServer, escapedFilePath);
|
||||||
|
|
||||||
curl_easy_setopt(dl->curl, CURLOPT_ENCODING, "");
|
curl_easy_setopt(dl->curl, CURLOPT_ENCODING, "");
|
||||||
curl_easy_setopt(dl->curl, CURLOPT_NOPROGRESS, 0);
|
|
||||||
|
|
||||||
if (dl->file)
|
if (dl->file)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +226,7 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl)
|
||||||
|
|
||||||
if (curl_multi_add_handle (multi, dl->curl) != CURLM_OK)
|
if (curl_multi_add_handle (multi, dl->curl) != CURLM_OK)
|
||||||
{
|
{
|
||||||
Com_Printf ("curl_multi_add_handle: error\n");
|
Com_Printf("HTTP download: cURL error\n");
|
||||||
dl->queueEntry->state = DLQ_STATE_DONE;
|
dl->queueEntry->state = DLQ_STATE_DONE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -301,7 +300,7 @@ static void CL_CheckAndQueueDownload(char *path)
|
||||||
strcmp(ext, "bsp") && strcmp(ext, "ent") && strcmp(ext, "txt") && strcmp(ext, "dm2") &&
|
strcmp(ext, "bsp") && strcmp(ext, "ent") && strcmp(ext, "txt") && strcmp(ext, "dm2") &&
|
||||||
strcmp(ext, "loc"))
|
strcmp(ext, "loc"))
|
||||||
{
|
{
|
||||||
Com_Printf ("WARNING: Illegal file type '%s' in filelist.\n", ext);
|
Com_Printf ("HTTP download: Illegal file type '%s' in filelist\n", ext);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +315,7 @@ static void CL_CheckAndQueueDownload(char *path)
|
||||||
{
|
{
|
||||||
if (pak)
|
if (pak)
|
||||||
{
|
{
|
||||||
Com_Printf("WARNING: @ prefix used on a pak file '%s' in filelist.\n", path);
|
Com_Printf("HTTP download: @ prefix used on a pak file '%s' in filelist\n", path);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +341,7 @@ static void CL_CheckAndQueueDownload(char *path)
|
||||||
if (strstr (path, "..") || strstr(path, "//") || strchr (path, '\\') ||
|
if (strstr (path, "..") || strstr(path, "//") || strchr (path, '\\') ||
|
||||||
(!pak && !strchr(path, '/')) || (pak && strchr(path, '/')))
|
(!pak && !strchr(path, '/')) || (pak && strchr(path, '/')))
|
||||||
{
|
{
|
||||||
Com_Printf("WARNING: Illegal path '%s' in filelist.\n", path);
|
Com_Printf("HTTP download: Illegal path '%s' in filelist\n", path);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -464,16 +463,12 @@ static void CL_ReVerifyHTTPQueue (void)
|
||||||
*/
|
*/
|
||||||
static void CL_FinishHTTPDownload(void)
|
static void CL_FinishHTTPDownload(void)
|
||||||
{
|
{
|
||||||
// TODO CURL: Einige können davon sicher noch weg.
|
|
||||||
size_t i;
|
|
||||||
int msgs_in_queue;
|
|
||||||
dlhandle_t *dl = NULL;
|
|
||||||
double timeTaken;
|
|
||||||
double fileSize;
|
|
||||||
char tempName[MAX_OSPATH];
|
|
||||||
|
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
|
char tempName[MAX_OSPATH];
|
||||||
|
dlhandle_t *dl = NULL;
|
||||||
|
int msgs_in_queue;
|
||||||
qboolean isFile;
|
qboolean isFile;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -569,10 +564,9 @@ static void CL_FinishHTTPDownload(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and remove it from the CURL multihandle.
|
// ...and remove it from the CURL multihandle.
|
||||||
curl_multi_remove_handle (multi, dl->curl);
|
curl_multi_remove_handle(multi, dl->curl);
|
||||||
|
|
||||||
// TODO CURL: Rausreißen?
|
Com_Printf("HTTP download: %s - File Not Found\n", dl->queueEntry->quakePath);
|
||||||
Com_Printf ("HTTP(%s): 404 File Not Found [%d remaining files]\n", dl->queueEntry->quakePath, pendingCount);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -584,18 +578,17 @@ static void CL_FinishHTTPDownload(void)
|
||||||
CL_ParseFileList(dl);
|
CL_ParseFileList(dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Com_Printf("HTTP download: %s - OK\n", dl->queueEntry->quakePath);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything that's not 200 and 404 is fatal, fall through.
|
|
||||||
// TODO CURL: Rausreißen?
|
|
||||||
Com_Printf("Bad HTTP response code %ld for %s, aborting HTTP downloading.\n", responseCode, dl->queueEntry->quakePath);
|
|
||||||
|
|
||||||
|
// Everything that's not 200 and 404 is fatal, fall through.
|
||||||
case CURLE_COULDNT_RESOLVE_HOST:
|
case CURLE_COULDNT_RESOLVE_HOST:
|
||||||
case CURLE_COULDNT_CONNECT:
|
case CURLE_COULDNT_CONNECT:
|
||||||
case CURLE_COULDNT_RESOLVE_PROXY:
|
case CURLE_COULDNT_RESOLVE_PROXY:
|
||||||
// TODO CURL: Rausreißen?
|
Com_Printf("HTTP download: %s - Server broken, aborting\n", dl->queueEntry->quakePath);
|
||||||
Com_Printf ("Fatal HTTP error: %s\n", curl_easy_strerror (result));
|
|
||||||
|
|
||||||
// The download failed. Remove the temporary file...
|
// The download failed. Remove the temporary file...
|
||||||
if (isFile)
|
if (isFile)
|
||||||
|
@ -621,8 +614,7 @@ static void CL_FinishHTTPDownload(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO CURL: Rausreißen?
|
Com_Printf ("HTTP download: cURL error - %s\n", curl_easy_strerror(result));
|
||||||
Com_Printf ("HTTP download failed: %s\n", curl_easy_strerror(result));
|
|
||||||
|
|
||||||
i = strlen(dl->queueEntry->quakePath);
|
i = strlen(dl->queueEntry->quakePath);
|
||||||
|
|
||||||
|
@ -658,11 +650,6 @@ static void CL_FinishHTTPDownload(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO CURL: Rausreißen?
|
|
||||||
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &timeTaken);
|
|
||||||
curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &fileSize);
|
|
||||||
Com_Printf("HTTP(%s): %.f bytes, %.2fkB/sec [%d remaining files]\n", dl->queueEntry->quakePath, fileSize, (fileSize / 1024.0) / timeTaken, pendingCount);
|
|
||||||
|
|
||||||
// Remove the file fo CURLs multihandle.
|
// Remove the file fo CURLs multihandle.
|
||||||
curl_multi_remove_handle (multi, dl->curl);
|
curl_multi_remove_handle (multi, dl->curl);
|
||||||
|
|
||||||
|
@ -851,7 +838,7 @@ void CL_SetHTTPServer (const char *URL)
|
||||||
// Initializes a new multihandle.
|
// Initializes a new multihandle.
|
||||||
if (multi)
|
if (multi)
|
||||||
{
|
{
|
||||||
Com_Error (ERR_DROP, "CL_SetHTTPServer: Still have old handle");
|
Com_Error(ERR_DROP, "HTTP download: Still have old handle?!");
|
||||||
}
|
}
|
||||||
|
|
||||||
multi = curl_multi_init();
|
multi = curl_multi_init();
|
||||||
|
@ -966,6 +953,8 @@ qboolean CL_QueueHTTPDownload(const char *quakePath)
|
||||||
// If we're here CL_FinishHTTPDownload() is guaranteed to be called.
|
// If we're here CL_FinishHTTPDownload() is guaranteed to be called.
|
||||||
pendingCount++;
|
pendingCount++;
|
||||||
|
|
||||||
|
Com_Printf("HTTP download: %s - Queued\n", q->quakePath);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1006,7 @@ void CL_RunHTTPDownloads(void)
|
||||||
// Somethings gone very wrong.
|
// Somethings gone very wrong.
|
||||||
if (ret != CURLM_OK)
|
if (ret != CURLM_OK)
|
||||||
{
|
{
|
||||||
Com_Printf("curl_multi_perform error. Aborting HTTP downloads.\n");
|
Com_Printf("HTTP download: cURL error\n");
|
||||||
CL_CancelHTTPDownloads(true);
|
CL_CancelHTTPDownloads(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,8 +351,6 @@ CL_Disconnect(void)
|
||||||
cls.downloadReferer[0] = 0;
|
cls.downloadReferer[0] = 0;
|
||||||
cls.downloadname[0] = 0;
|
cls.downloadname[0] = 0;
|
||||||
cls.downloadposition = 0;
|
cls.downloadposition = 0;
|
||||||
// TODO CURL: Rausreißen?
|
|
||||||
// CL_Download_Reset_KBps_counter();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
|
@ -596,17 +594,13 @@ CL_ConnectionlessPacket(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Netchan_Setup(NS_CLIENT, &cls.netchan, net_from, cls.quakePort);
|
Netchan_Setup(NS_CLIENT, &cls.netchan, net_from, cls.quakePort);
|
||||||
|
|
||||||
// TODO CURL: Das erscheint mir sinnlos kompliziert und ist für
|
|
||||||
// den Fall ohne CURL wahrscheinlich recht spammy.
|
|
||||||
|
|
||||||
char *buff = NET_AdrToString(cls.netchan.remote_address);
|
char *buff = NET_AdrToString(cls.netchan.remote_address);
|
||||||
|
|
||||||
for (int i = 1; i < Cmd_Argc(); i++)
|
for(int i = 1; i < Cmd_Argc(); i++)
|
||||||
{
|
{
|
||||||
char *p = Cmd_Argv(i);
|
char *p = Cmd_Argv(i);
|
||||||
|
|
||||||
if (!strncmp (p, "dlserver=", 9))
|
if(!strncmp(p, "dlserver=", 9))
|
||||||
{
|
{
|
||||||
#ifdef USE_CURL
|
#ifdef USE_CURL
|
||||||
p += 9;
|
p += 9;
|
||||||
|
|
Loading…
Reference in a new issue