From 1f34ed674026b63df2b37d5f968820b715b70835 Mon Sep 17 00:00:00 2001 From: Learath Lea Date: Fri, 13 Mar 2015 21:17:23 +0200 Subject: [PATCH] Call the completion callback even on a fail. --- src/engine/client/fetcher.cpp | 14 ++++++++------ src/engine/client/fetcher.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/engine/client/fetcher.cpp b/src/engine/client/fetcher.cpp index 89c7b31a1..81172ad84 100644 --- a/src/engine/client/fetcher.cpp +++ b/src/engine/client/fetcher.cpp @@ -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++) { @@ -126,18 +126,20 @@ bool CFetcher::FetchFile(CFetchTask *pTask) dbg_msg("fetcher", "Downloading %s", pTask->m_pDest); pTask->m_State = CFetchTask::STATE_RUNNING; int ret = curl_easy_perform(m_pHandle); + io_close(File); if(ret != CURLE_OK) { dbg_msg("fetcher", "Task failed. libcurl error: %s", aErr); pTask->m_State = (ret == CURLE_ABORTED_BY_CALLBACK) ? CFetchTask::STATE_ABORTED : CFetchTask::STATE_ERROR; - return false; } - io_close(File); - dbg_msg("fetcher", "Task done %s", pTask->m_pDest); - pTask->m_State = CFetchTask::STATE_DONE; + else + { + dbg_msg("fetcher", "Task done %s", pTask->m_pDest); + pTask->m_State = CFetchTask::STATE_DONE; + + } if(pTask->m_pfnCompCallback) pTask->m_pfnCompCallback(pTask, pTask->m_pUser); - return true; } void CFetcher::WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile) diff --git a/src/engine/client/fetcher.h b/src/engine/client/fetcher.h index 7803f5ea5..9096e75e9 100644 --- a/src/engine/client/fetcher.h +++ b/src/engine/client/fetcher.h @@ -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 Escape(char *pBud, size_t size, const char *pStr); 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 int ProgressCallback(void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr); };