Small fixes. Remove superflous log messages.
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define DOWNLOAD_DELAY_MSEC 10
|
#define DOWNLOAD_DELAY_MSEC 20
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
@@ -128,8 +128,6 @@ DownloaderThread::Main()
|
|||||||
if (m_curDownloadData && !m_curDownloadData->filename.empty())
|
if (m_curDownloadData && !m_curDownloadData->filename.empty())
|
||||||
{
|
{
|
||||||
path filepath(m_curDownloadData->filename);
|
path filepath(m_curDownloadData->filename);
|
||||||
LOG_MSG("URL: " + m_curDownloadData->address);
|
|
||||||
LOG_MSG("File: " + filepath.file_string());
|
|
||||||
m_downloadHelper->Init(m_curDownloadData->address, filepath.file_string());
|
m_downloadHelper->Init(m_curDownloadData->address, filepath.file_string());
|
||||||
m_downloadInProgress = true;
|
m_downloadInProgress = true;
|
||||||
}
|
}
|
||||||
@@ -137,7 +135,7 @@ DownloaderThread::Main()
|
|||||||
}
|
}
|
||||||
catch (const NetException &e)
|
catch (const NetException &e)
|
||||||
{
|
{
|
||||||
LOG_ERROR(e.what());
|
LOG_ERROR("Download failed: " << e.what());
|
||||||
m_downloadInProgress = false;
|
m_downloadInProgress = false;
|
||||||
m_curDownloadData.reset();
|
m_curDownloadData.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ DownloadHelper::InternalInit(const string &/*url*/, const string &targetFileName
|
|||||||
throw NetException(__FILE__, __LINE__, ERR_SOCK_TRANSFER_OPEN_FAILED, 0);
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_TRANSFER_OPEN_FAILED, 0);
|
||||||
|
|
||||||
// Assume that the following calls never fail.
|
// Assume that the following calls never fail.
|
||||||
|
// NOTE: A writefunction needs to be set if a DLL version of curl is used on Windows.
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_WRITEFUNCTION, NULL);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_WRITEFUNCTION, NULL);
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_WRITEDATA, GetData()->targetFile);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_WRITEDATA, GetData()->targetFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ UploaderThread::Main()
|
|||||||
if (!m_uploadInProgress)
|
if (!m_uploadInProgress)
|
||||||
{
|
{
|
||||||
Msleep(UPLOAD_DELAY_MSEC);
|
Msleep(UPLOAD_DELAY_MSEC);
|
||||||
|
// The upload needs only local state, as no value needs to be returned.
|
||||||
UploadData data;
|
UploadData data;
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_uploadQueueMutex);
|
boost::mutex::scoped_lock lock(m_uploadQueueMutex);
|
||||||
@@ -80,7 +81,7 @@ UploaderThread::Main()
|
|||||||
}
|
}
|
||||||
catch (const NetException &e)
|
catch (const NetException &e)
|
||||||
{
|
{
|
||||||
LOG_ERROR(e.what());
|
LOG_ERROR("Upload failed: " << e.what());
|
||||||
m_uploadInProgress = false;
|
m_uploadInProgress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ using namespace std;
|
|||||||
size_t
|
size_t
|
||||||
readFunction(char *bufptr, size_t size, size_t nitems, void *userp)
|
readFunction(char *bufptr, size_t size, size_t nitems, void *userp)
|
||||||
{
|
{
|
||||||
FILE *tmpFile = (FILE *)userp;
|
return fread(bufptr, size, nitems, (FILE *)userp);
|
||||||
int ret = fread(bufptr, size, nitems, tmpFile);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadHelper::UploadHelper()
|
UploadHelper::UploadHelper()
|
||||||
@@ -57,7 +55,7 @@ UploadHelper::InternalInit(const string &/*url*/, const string &targetFileName,
|
|||||||
// Assume that the following calls never fail.
|
// Assume that the following calls never fail.
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_READFUNCTION, readFunction);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_READFUNCTION, readFunction);
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_READDATA, GetData()->targetFile);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_READDATA, GetData()->targetFile);
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_INFILESIZE, (curl_off_t)filesize);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_INFILESIZE, filesize);
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_USERPWD, GetData()->userCredentials.c_str());
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_USERPWD, GetData()->userCredentials.c_str());
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_UPLOAD, 1L);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_UPLOAD, 1L);
|
||||||
curl_easy_setopt(GetData()->curlHandle, CURLOPT_PUT, 1L);
|
curl_easy_setopt(GetData()->curlHandle, CURLOPT_PUT, 1L);
|
||||||
|
|||||||
Reference in New Issue
Block a user