code from libcurl, or 0, if another error has occurred.
====================
*/
+static qboolean Curl_Begin(const char *URL, const char *name, qboolean ispak, qboolean forthismap, unsigned char *buf, size_t bufsize, curl_callback_t callback, void *cbdata);
static void Curl_EndDownload(downloadinfo *di, CurlStatus status, CURLcode error)
{
qboolean ok = false;
FS_Close(di->stream);
if(ok && di->ispak)
+ {
ok = FS_AddPack(di->filename, NULL, true);
+ if(!ok)
+ {
+ // pack loading failed?
+ // this is critical
+ // better clear the file again...
+ di->stream = FS_OpenRealFile(di->filename, "wb", false);
+ FS_Close(di->stream);
+
+ if(di->startpos && !di->callback)
+ {
+ // this was a resume?
+ // then try to redownload it without reporting the error
+ Curl_Begin(di->url, di->filename, di->ispak, di->forthismap, NULL, 0, NULL, NULL);
+ di->forthismap = false; // don't count the error
+ }
+ }
+ }
if(di->prev)
di->prev->next = di->next;
}
else
{
- qfile_t *f = FS_OpenVirtualFile(fn, false);
+ qfile_t *f = FS_OpenRealFile(fn, "rb", false);
if(f)
{
char buf[4] = {0};
di->startpos = 0;
di->curle = NULL;
di->started = false;
- di->ispak = ispak;
+ di->ispak = (ispak && !buf);
di->bytes_received = 0;
di->next = downloads;
di->prev = NULL;