Changed: Minor changes

--HG--
branch : develop
This commit is contained in:
kervala 2016-10-27 16:48:07 +02:00
parent 1362e2d470
commit 482b292a03

View file

@ -1416,6 +1416,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
// file not found, delete local file // file not found, delete local file
throw Exception ("curl init failed"); throw Exception ("curl init failed");
} }
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, downloadProgressFunc); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, downloadProgressFunc);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *) progress); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *) progress);
@ -1427,12 +1428,15 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
setRWAccess(dest, false); setRWAccess(dest, false);
NLMISC::CFile::deleteFile(dest.c_str()); NLMISC::CFile::deleteFile(dest.c_str());
} }
FILE *fp = nlfopen (dest, "wb"); FILE *fp = nlfopen (dest, "wb");
if (fp == NULL) if (fp == NULL)
{ {
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
throw Exception ("Can't open file '%s' for writing: code=%d %s (error code 37)", dest.c_str (), errno, strerror(errno)); throw Exception ("Can't open file '%s' for writing: code=%d %s (error code 37)", dest.c_str (), errno, strerror(errno));
} }
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);