mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Call the completion callback even on a fail.
This commit is contained in:
parent
62da96b518
commit
1f34ed6740
|
@ -91,7 +91,7 @@ void CFetcher::FetcherThread(void *pUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFetcher::FetchFile(CFetchTask *pTask)
|
void CFetcher::FetchFile(CFetchTask *pTask)
|
||||||
{
|
{
|
||||||
for(int i = 0; pTask->m_pDest[i] != '\0'; i++)
|
for(int i = 0; pTask->m_pDest[i] != '\0'; i++)
|
||||||
{
|
{
|
||||||
|
@ -126,18 +126,20 @@ bool CFetcher::FetchFile(CFetchTask *pTask)
|
||||||
dbg_msg("fetcher", "Downloading %s", pTask->m_pDest);
|
dbg_msg("fetcher", "Downloading %s", pTask->m_pDest);
|
||||||
pTask->m_State = CFetchTask::STATE_RUNNING;
|
pTask->m_State = CFetchTask::STATE_RUNNING;
|
||||||
int ret = curl_easy_perform(m_pHandle);
|
int ret = curl_easy_perform(m_pHandle);
|
||||||
|
io_close(File);
|
||||||
if(ret != CURLE_OK)
|
if(ret != CURLE_OK)
|
||||||
{
|
{
|
||||||
dbg_msg("fetcher", "Task failed. libcurl error: %s", aErr);
|
dbg_msg("fetcher", "Task failed. libcurl error: %s", aErr);
|
||||||
pTask->m_State = (ret == CURLE_ABORTED_BY_CALLBACK) ? CFetchTask::STATE_ABORTED : CFetchTask::STATE_ERROR;
|
pTask->m_State = (ret == CURLE_ABORTED_BY_CALLBACK) ? CFetchTask::STATE_ABORTED : CFetchTask::STATE_ERROR;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
io_close(File);
|
else
|
||||||
dbg_msg("fetcher", "Task done %s", pTask->m_pDest);
|
{
|
||||||
pTask->m_State = CFetchTask::STATE_DONE;
|
dbg_msg("fetcher", "Task done %s", pTask->m_pDest);
|
||||||
|
pTask->m_State = CFetchTask::STATE_DONE;
|
||||||
|
|
||||||
|
}
|
||||||
if(pTask->m_pfnCompCallback)
|
if(pTask->m_pfnCompCallback)
|
||||||
pTask->m_pfnCompCallback(pTask, pTask->m_pUser);
|
pTask->m_pfnCompCallback(pTask, pTask->m_pUser);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFetcher::WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile)
|
void CFetcher::WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual void QueueAdd(CFetchTask *pTask, const char *pUrl, const char *pDest, int StorageType = 2, void *pUser = 0, COMPFUNC pfnCompCb = 0, PROGFUNC pfnProgCb = 0);
|
virtual void QueueAdd(CFetchTask *pTask, const char *pUrl, const char *pDest, int StorageType = 2, void *pUser = 0, COMPFUNC pfnCompCb = 0, PROGFUNC pfnProgCb = 0);
|
||||||
virtual void Escape(char *pBud, size_t size, const char *pStr);
|
virtual void Escape(char *pBud, size_t size, const char *pStr);
|
||||||
static void FetcherThread(void *pUser);
|
static void FetcherThread(void *pUser);
|
||||||
bool FetchFile(CFetchTask *pTask);
|
void FetchFile(CFetchTask *pTask);
|
||||||
static void WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile);
|
static void WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile);
|
||||||
static int ProgressCallback(void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr);
|
static int ProgressCallback(void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue