]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
curl: delete the downloaded pk3 if adding it failed
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 22 Mar 2009 19:31:07 +0000 (19:31 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 22 Mar 2009 19:31:07 +0000 (19:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8820 d7cf8633-e32d-0410-b094-e92efae38249

libcurl.c

index 28b18f5f94417d2636e90aade839e0030f92de2a..58c017857fe9fa9d2dd7eba9c7b6f29ff51bc693 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -491,7 +491,17 @@ static void Curl_EndDownload(downloadinfo *di, CurlStatus status, CURLcode error
                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->prev)
                di->prev->next = di->next;
@@ -748,7 +758,7 @@ static qboolean Curl_Begin(const char *URL, const char *name, qboolean ispak, qb
                                }
                                else
                                {
-                                       qfile_t *f = FS_OpenVirtualFile(fn, false);
+                                       qfile_t *f = FS_OpenRealFile(fn, "rb", false);
                                        if(f)
                                        {
                                                char buf[4] = {0};